vbmithr / ocaml-websocket

Websocket library for OCaml
ISC License
162 stars 44 forks source link

Strange bug that leads to Unix.ECONNREFUSED #68

Open tobiasBora opened 7 years ago

tobiasBora commented 7 years ago

Hello,

First thank you for the library. However I'm having some bugs I cannot explain. I manage to make it work between a python server and an ocaml client, but when the ocaml client tries to connect to the well known wscat (sudo apt-get install node-ws) which is run as a server with :

/usr/bin/wscat --listen 8889

I got an error from the client side:

Exception: Unix.Unix_error (Unix.ECONNREFUSED, "connect", "").

The code I'm running is the wscat installed by opam (I also tried to compile it by myself, and the bug stay the same). I checked with netcat the opened port and I find the 8889:

$netstat --listen | grep 8889
tcp        0      0 0.0.0.0:8889            0.0.0.0:*               LISTEN  

Also, I tried to connect to the node wscat using both a node wscat client and a python client running websocket, and both can connect to the server, so it's indeed a bug.

Do you know what could be the reason of such a bug ?

Thank you.

vbmithr commented 7 years ago

I think the issue you had is that the OCaml wscat client was trying to connect to the IPv6 localhost (::1) instead of 127.0.0.1. Could you please try ./wscat.native "http://127.0.0.1:8889"?