pylessard / python-udsoncan

Python implementation of UDS (ISO-14229) standard.
MIT License
564 stars 195 forks source link

TimeoutError: timed out #231

Closed p31d4 closed 1 month ago

p31d4 commented 3 months ago

Hi,

I'm trying to send a can message in a virtualized Linux machine (VM on native Windows), and a keep receiving a timeout in tpsock/init.py line 108 (self._socket.send(data,flags)) when I run the following code:

with Client(conn,  request_timeout=2, config=config) as client:
    client.tester_present()

The bus is working properly (I've tested it with can-utils) and the problem is somehow related to the "select" API, on method "rxthread_task". I've also tried the branch "fix_socket_connection_that_blocks_on_open_close", but the problem was still there.

I fixed the problem locally re-writiing the method "rxthread_task" as:

while True:
    try:
        time.slee(0.2)
        data = self.tpsock.recv()
        if data is None:
            break
        else:
            self.rxqueue.put(data)
    except Exception:
        pass

Looks like the "select" API is blocking forever, but I'm not entirely sure.

Does someone already experienced this timeout issue and has any clue how to fix it without having to re-write the code?

Thanks and regards

pylessard commented 2 months ago

Possible that you don't open the connection properly like in the other issue? If you want help to debug, share how you configure your setup.

pompushko commented 2 months ago

@pylessard Hello :)

I dont know, if should be a new issue ticket, but sometimes my timeout settings wont respects...

                client = Client(conn, request_timeout=5)
                client.open()
                client.set_config('exception_on_negative_response', False)
                client.set_config('exception_on_timeout', False)
                client.set_config('p2_timeout', 10.0)
                client.set_config('p2_server_max', 10.0)
                client.set_config('request_timeout', 10.0)
                client.set_config('p2_star_timeout', 10.0)
                client.set_config('use_server_timing', False)

And sometimes my code throw this: [TimeoutException] : Did not receive response in time. Global request timeout time has expired (timeout=1.968 sec)

Why? Where is takes timeout=1.968 sec? Thank you.

p31d4 commented 2 months ago

@pylessard thanks for the replay, from my side this issue can be close.