question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using https with socket.io 1.0.6 and getting an ERR_SSL_PROTOCOL_ERROR

See original GitHub issue

I’ve been using https with socket.io on version 0.9 and below successfully for years. I went to upgrade to the new 1.0 version and I’m getting an SSL error. Here is the server-side node.js code to start the socket server:

var options = {};
options.key = fs.readFileSync('certs/ssh.key');
options.cert = fs.readFileSync('certs/cert.key'); //I've also tried using the property 'certificate' instead of 'cert'
var io = require('socket.io').listen(9091,options);

The connection works fine over standard http but https is giving me the error: ERR_SSL_PROTOCOL_ERROR

I know that all certificate file references are good. There seems to be no documentation on how to implement https socket.io connections on version 1.0, so I’m at a loss. Any help is much appreciated.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
gabereisercommented, Jul 14, 2014

try binding to an http server first using express or the like using https, then attach Socket.IO to that.

var fs = require('fs');
var https = require('https');
var server = https.createServer({
  key: fs.readFileSync('key'),
  cert: fs.readFileSync('cert')
});

var eio = require('engine.io').attach(server);
var io = require('socket.io').listen(server);
0reactions
darrachequesnecommented, Jan 12, 2017

That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible).

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Using https with socket.io 1.0.6 and getting an ...
I went to upgrade to the new 1.0 version and I'm getting an SSL error. Here is the server-side node.js code to start...
Read more >
Troubleshooting connection issues | Socket.IO
First and foremost, please note that disconnections are common and expected, even on a stable Internet connection:
Read more >
Everything you need to know about Socket.IO - Ably Realtime
A popular way to demonstrate the two-way communication Socket.IO provides is a basic chat app (we talk about some other use cases below)....
Read more >
ngx-socket-io - npm
Make sure you're using the proper corresponding version of socket.io on the server. Package Version, Socket-io Server Version, Angular version ...
Read more >
Use HTTPS / Socket.io in development environment
GET https ://develop.[domain].com:9000/socket.io/?EIO=3&transport=polling&t=Mfq3F1I net::ERR_CONNECTION_CLOSED libs.min.js?ver=1556712335.0:1234:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found