koush / AndroidAsync

Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads.
Other
7.51k stars 1.56k forks source link

Fix client timeout caused by AsyncNetworkSocket write() #684

Open jhihn opened 3 years ago

jhihn commented 3 years ago

There is a problem when a large (>345 kB) message is being written to a websocket. The connection will actually time out, unless this while is in place. Unfortunately, this pretty much busy-waits. But whatever the queueing mechanism is, is broken at least for websockets and large messages. My messages are ~2MB.

.154 AndroidAsync: before:1926139
.154 AndroidAsync: remaining:1577171
.156 AndroidAsync: before:1926139
.156 AndroidAsync: remaining:1577171
.158 AndroidAsync: before:1926139
...
.240 AndroidAsync: remaining:0

Without this, your connection will be dropped by the remote side. Tested with C++ qtwebsockets and Python websockets clients.

The two part write()/handleRemaining() does not seem to handlw when handleRemaining() still has remaining properly.

AntoG735 commented 3 years ago

I have the same problem, when the PR can be approved ? :)

jhihn commented 3 years ago

I don't think the PR is proper, it just "fixes" the problem in a nuclear way. The gh github client can probably cherry pick this for you.