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

Allow web socket client to be overridden #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

activelylazy
Copy link

I'd like to be able to provide a different StandardWebSocketClient, to allow control of error behaviours and transparently re-connect the connection to slack - to do that I'd need to make client protected, so I can override in my sub-class.

@rampatra
Copy link
Owner

Thanks for the PR. Can this be done by overriding handleTransportError() method?

@activelylazy
Copy link
Author

Oh, good question - I don't know. Not sure if I tried it, or maybe I did and it didn't work in some case. I'll try again and let you know if this PR is still required.

@activelylazy
Copy link
Author

activelylazy commented Mar 26, 2018

Ok checked the logs and I'm not seeing handleTransportError getting called.

The error I see logged looks like this:

2018-01-09 19:17:05,981 ERROR SimpleAsyncTaskExecutor-1 org.springframework.web.socket.client.WebSocketConnectionManager - Failed to connect             
javax.websocket.DeploymentException: The HTTP response from the server [503] did not permit the HTTP upgrade to WebSocket                                
        at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:346)                                               
        at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:150)                               
        at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:147)                               
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)         
        at java.lang.Thread.run(Thread.java:748)                            

The future returned from WebSocketClient.doHandshake sees this error (since WebSocketConnectionManager can log it). I'm thinking to create a new StandardWebSocketClient, which overrides doHandshake to register a failure callback on the returned future. I can then use that callback to trigger a re-connect.

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

Successfully merging this pull request may close these issues.

2 participants