Skip to content

TCP connection seems to block until timeout #28

@yerpj

Description

@yerpj

Hi,

I don't know if this is the best place to share my thoughts, but I didn't find any Particle room on Gitter.
I am playing with the HttpClient in order to POST some data from my Particle Core to a nodejs http server on my local network.
Globally it works. But It seems that the http.post() method is blocking until timeout. I think it could come from the line 237 of HttpClient.cpp (}while (client.connected() && !timeout && !error);). Let me explain why:

When in local network, the server could potentially respond to a request very quickly. Furthermore, it is stated in Particle reference that client.connected() returns TRUE if the socket is still open OR if there is any data remaining in the RX buffer. So if the server answers quickly, due to line 235 delay(200);, the client is likely to get some data BEFORE client.connected() is called. In my opinion, this could lead to block the http.post request in the do{}while() loop UNTIL timeout. Thereby, I am experiencing this behaviour right now. The POST request is sent in less than 100ms, then the server answers in less than 2ms. After that, I see some traffic (with Wireshark) sur as [PSH,ACK],[RST,ACK],as well as retransmissions for about 5.5 seconds. Finally, the client sends the [FIN,ACK] packet. I tried to address a distant server, the complete request-response is during max 2 seconds.
I also looked at the Particle forum, nobody seems to talk about that issue, maybe I'm totally wrong and misunderstood the TCP protocol. On demand, I can explore further.

Here is the wireshark log: http://s000.tinyupload.com/?file_id=09753784621306542778

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions