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

Error: socket hang up #1390

Closed
pepe95270 opened this issue May 25, 2018 · 1 comment
Closed

Error: socket hang up #1390

pepe95270 opened this issue May 25, 2018 · 1 comment

Comments

@pepe95270
Copy link

pepe95270 commented May 25, 2018

Hello all,
I get an issue when simply trying to connect to a server via WebSocket.
Here is my code:

const WebSocket = require('ws');
const ws = new WebSocket('http://172.21.178.165:8080');

ws.on('open', function open() {
  ws.send('Start video HoloLens');
});

And I get

Error: socket hang up
at createHangUpError (_http_client.js:331:15)
at Socket.socketOnEnd (_http_client.js:423:23)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

If I try connecting to the same address with Chrome and socket.io, it works well:

<script src="/socket.io.js"></script>
<script>var socket = io.connect('http://172.21.178.165:8080');</script>

I've attached the result of this connection, you can see that it is working as expected.
sans titre

Someone has an idea why I get this socket hang up error?

I also tried using this library to have a websocket client but I get a similar error, so I guess I've done something wrong or it's the fault of the library used under the hood to send the initial request or other request that is buggy? Any suggestion is very appreciated :)

NodeJS version 8.9.4
ws version 5.2.0
(request version 2.85.0)
OS: Windows 10

Thanks,
Pierre

@lpinca
Copy link
Member

lpinca commented May 25, 2018

You are not connecting to the same path, look at the url in your screenshot and the url you used in the WebSocket constructor, they are not the same.

Also using plain WebSocket to talk with a Socket.IO server does not work seamlessly.

@lpinca lpinca closed this as completed May 27, 2018
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