clj-commons / clj-commons/aleph

Add timeout params to websocket client

Open
#346 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue
Dominant language
Clojure
Stars
2.6k
Forks
242
Avg merge
4d 5h
Merged PRs (30d)
1

Description

Hello,

I have a number of client devices connecting as websocket clients to a server. To handle network interruptions, I reconnect to the WS server after each disconnection, with some backoff, etc.

Some of these devices are on unreliable networks, and I'm sometimes seeing `websocket-client` fail to time out and simply hang indefinitely. I think what's happening is that the actual socket connection is succeeding, but then the client is losing connectivity during the handshake. Without a keepalive on the TCP connection, or a timeout handler on the Netty channel, the deferred never succeeds or fails.

I'm using `deferred/timeout!` to work around this but I'm not sure what's happening under the hood - i.e. whether or this means that sockets/resources are still allocated and hanging around forever in the background.

Adding an `IdleStateHandler` to the Netty channel while the handshake is in progress might fix this.

Alex

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the websocket client handshake and its Netty channel, with particular attention to the proposed IdleStateHandler. Compare this behavior with the existing deferred/timeout! workaround. Done means supported timeout parameters prevent handshakes from hanging indefinitely without leaving socket or other resources allocated.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
backend, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.