Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unstable connection: disconnects, slow responses, lots of retransmissions #27

Closed
bertmelis opened this issue Nov 19, 2018 · 2 comments
Closed

Comments

@bertmelis
Copy link

bertmelis commented Nov 19, 2018

I'm struggling to get the lib working for a simple modbus master. I can't even connect to the server.
Wireshark shows a remarkable log:
image

Even though the ESP is already connected, it resends SYN. Also, it takes about 3 seconds before the ESP knows it has connected (wireshark show it about 3 secs sooner).

From time to time, I experience stranger errors like [E][AsyncTCP.cpp:571] _recv(): 0x3ffbb578 != 0x3ffbb120

Behaviour is the same for the main branch as the idf-update branch. The _recv() only appears at the idf-update branch.

Edit: when the _recv() error appears, there's no callback called, so my app also doesn't know it can move on. As a workaround I need to implement a timer myself.

@bertmelis
Copy link
Author

bertmelis commented Nov 24, 2018

So what I believe is happening:

  • I call client.connect()
  • I call client.connect() again, assuming it would just return because it is already connecting. However, as my Wireshark analysis shows, it is creating a new connection.
  • AsyncClient connects, but it calls my onConnected several times: for each call I made to connect().
  • After being connected, I start with regular communication.
  • Because I only use the "lastest" connection, the other ones get idle and get disconnected by the server.
  • AsyncClient treats the disconnect from the first connections as a disconnect for the active connection in the middle of active communication.

I thought solving this by

if (!client.connected() && !client.connecting()) {
  client.connect();
}

But AsyncClient takes a few seconds before being aware that it is connecting. Setting the priority of the asynctask higher improves, but is still not aware of it's state directly after calling connect(). Surely it is a issue with FreeRTOS's task switching latency.

So basically:
Is this intended behaviour and should I deal with this myself?
Or is it an issue that has to be solved in AsyncClient?

@bertmelis
Copy link
Author

Closing for now...
Probably has something to do with

  • bad WiFi reception
  • data coming after disconnect
  • ack timeouts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant