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

WebSocket connection to 'ws://localhost:9160/' failed: Connection closed before receiving a handshake response #64

Open
adinapoli opened this issue Apr 13, 2014 · 5 comments

Comments

@adinapoli
Copy link

Hi Jasper! :)

I have stumble upon a peculiar behaviour when hacking on the Tidal project: in a nutshell trying to establish a connection on port 9160 on my machine (Mac OS X 10.9.2 Maverick with GHC 7.8.2) fails in different flavours, whereas with any other ports (e.g 9161) seems to work. How I reproduced it:

  • I have run the example's server.lhs and then trying to join the chatroom opening client.html. This is the error in the JS console of my browser (chrome):
WebSocket connection to 'ws://localhost:9160/' failed: Connection closed before receiving a handshake response 

If I change the port on both sides (server and client.js) the connection works. I though at first it might have been that port 9160 is already taken by some service, but netstat -a | grep 9160 shows nothing. It's interesting though, because this seems to be exactly the problem; I've got the same error trying to open a socket on a port already taken (.e.g 5432 is where my postgresql listen); the server.lhs didn't complain, but the client.js did. But in this last example, netstat -a was clearly indicanting that port 5432 was occupied.

On Tidal I had to submit this PR:

https://github.com/yaxu/Tidal/pull/21

because this line:

https://github.com/yaxu/Tidal/blob/master/Sound/Tidal/Tempo.hs#L167

was throwing an exception like "ghc: Parse exception: not enough input".

I think the two scenarios are somewhat related, but I do not have a clue about what's going on here and how come it seems to happen on just that port, even though according to netstat -a it should be available.

Any insight?
Thanks, and see you at the ZuriHack :P

Alfredo

@jaspervdj
Copy link
Owner

Hey Alfredo! I think Mac only shows used port for your own processes. This thread seems to confirm that: http://stackoverflow.com/questions/4421633/who-is-listening-on-a-given-tcp-port-on-mac-os-x. Perhaps try with the sudo lsof solution described in the first answer?

@adinapoli
Copy link
Author

Sure, I'll do that as soon as I get home and update the issue accordingly :)

Thanks Jasper!

@adinapoli
Copy link
Author

@jaspervdj haha, bingo!
I had a java process listening (probably Cassandra).
Glad it was a simple cause which triggered the error, even though is a bit confusing in both its incarnations (aka the error reported in the title on this PR and the one in the PR I linked you).
How difficult would be to fail with a more descriptive error message?

Cheers!
Alfredo

@jaspervdj
Copy link
Owner

B
On Apr 14, 2014 5:26 PM, "Alfredo Di Napoli" [email protected]
wrote:

Sure, I'll do that as soon as I get home and update the issue accordingly
:)

Thanks Jasper!


Reply to this email directly or view it on GitHub.

@adinapoli
Copy link
Author

@jaspervdj didn't you get the latest update?
In a nutshell yes the problem was an occupied port of my machine, and I'm leaving this open just to discuss whether we can make WS gracefully fail with a more descriptive message :)

Feel free to close the issue if you think nothing can be done in this direction :)

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

2 participants