Reputation: 157
I have a problem when uplaoding my code server to Heroku. There is no socket connexion message. This is the code of the server side on Heroku
var appS = require('express')();
var http = require('http').Server(appS);
var io = require('socket.io')(http,{path: '/octagon/socket.io'});
http.listen(3000, function(){
console.log('listening on *:3000');
});
io.sockets.on('connection', function (socket) {
socket.on('test',function (message) {
console.log(message)
})
})
And this is the code for client
var socket = io.connect('https://murmuring-waters-83521.herokuapp.com/',
{
reconnect: true,
transports : ['websocket'],
ressources: '/octagon/socket.io'
});
I Still get this message
WebSocket connection to 'wss://murmuring-waters-83521.herokuapp.com/octagon/socket.io/?EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 503
Upvotes: 2
Views: 412
Reputation: 2042
You can get this to work by updating the client config
var socket = io('//murmuring-waters-83521.herokuapp.com',
{
reconnect: true,
rejectUnauthorized: false, // new
path: '/octagon/socket.io' // use this instead of `ressources`
});
socket.on('connection', function () {
alert('Browser is connected to server!');
});
Upvotes: 1