python-udsoncan icon indicating copy to clipboard operation
python-udsoncan copied to clipboard

TimeoutError: timed out

Open p31d4 opened this issue 1 year ago • 3 comments

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

p31d4 avatar Apr 13 '24 23:04 p31d4

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.

pylessard avatar Apr 27 '24 00:04 pylessard

@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.

pompushko avatar May 16 '24 10:05 pompushko

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

p31d4 avatar May 22 '24 19:05 p31d4