pyshark icon indicating copy to clipboard operation
pyshark copied to clipboard

TShark seems to have crashed (retcode: 2). Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshar

Open seanachao opened this issue 3 years ago • 14 comments

my code example1

        caps = pyshark.FileCapture(self.filename)
        caps.set_debug()
        #self.caps_len = len(caps)
    
        src_host = ""
        dst_host = ""
        flow_packet = 0
        flow_bytes = 0
        index = 0 
        for counter,packet in enumerate(caps):
            if 'tcp' in dir(packet):
                #print(packet.tcp.stream)
                print(counter)
                src_host = packet.ip.src
                dst_host = packet.ip.dst
                flow_packet += 1
                flow_bytes += int(packet.tcp.len,10)
                if packet.tcp.stream not in self.features:
                    self.features.update({packet.tcp.stream:[src_host,dst_host,flow_packet,flow_bytes]})
                else:
                    self.features[packet.tcp.stream][2]+=1  #ToDoList
                    self.features[packet.tcp.stream][3]+=flow_bytes
                    pass #todo list

        return src_host,dst_host,flow_packet,flow_bytes

there was wrong

TShark seems to have crashed (retcode: 2). Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshar

but if I use code example2

    file = './peer0.org1.pcap'
    cap = pyshark.FileCapture(file)
    #cap.load_packets(timeout=100000000)
    #cap.set_debug()
    for counter, pkt in enumerate(cap):
        if "tcp" in dir(pkt):
            print(pkt.tcp.stream)
            print(counter)

there not any wrong , what should I do my example1 could work normal?

seanachao avatar Dec 08 '21 03:12 seanachao

I have the same problem :(

emptymo avatar Apr 15 '22 10:04 emptymo

same problem but happened on sniff method

luoyexiaohe avatar Apr 26 '22 03:04 luoyexiaohe

Same problem here when reading a capture with FileCapture

GiovanniColonni avatar Apr 29 '22 09:04 GiovanniColonni

gays, I know how to deal with this. call the function named set_debug ,then you could see what's the problem in console. my problem is that my wireshark is break. when I install it again , problem gone . good luck !

luoyexiaohe avatar Apr 29 '22 09:04 luoyexiaohe

You need version correspondence me : Wireshark-win64-2.4.2/ pyshark==0.4.2.7 This error will also occur if you illegally block and intercept good luck!

wangzeyu9766 avatar Jul 12 '22 07:07 wangzeyu9766

Is there any mapping for Wireshark-Version / pyshark_version compatibility?

vladenache13 avatar Mar 01 '23 15:03 vladenache13

same question. It turns out that the pcap file was appears to have been cut short in the middle of a packet.. This should not cause a crash, pyshark should just ignore the notice.

herugen avatar Apr 23 '23 12:04 herugen

Same issue, need support in handling this error "appears to have been cut short in the middle of a packet"

sindhuh1 avatar Mar 04 '24 19:03 sindhuh1

gays, I know how to deal with this. call the function named set_debug ,then you could see what's the problem in console. my problem is that my wireshark is break. when I install it again , problem gone . good luck !

does this mean you reinstalled wireshark and the issue is fixed after that?

sindhuh1 avatar Mar 04 '24 19:03 sindhuh1

gays, I know how to deal with this. call the function named set_debug ,then you could see what's the problem in console. my problem is that my wireshark is break. when I install it again , problem gone . good luck !

does this mean you reinstalled wireshark and the issue is fixed after that?

yes

luoyexiaohe avatar Mar 05 '24 12:03 luoyexiaohe

gays, I know how to deal with this. call the function named set_debug ,then you could see what's the problem in console. my problem is that my wireshark is break. when I install it again , problem gone . good luck !

does this mean you reinstalled wireshark and the issue is fixed after that?

but U should call the function first ,and get what's the problem with you.

luoyexiaohe avatar Mar 05 '24 12:03 luoyexiaohe