Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Connection closed before receiving a handshake response #84

Closed
huytran0605 opened this issue Aug 15, 2017 · 7 comments
Closed

Connection closed before receiving a handshake response #84

huytran0605 opened this issue Aug 15, 2017 · 7 comments

Comments

@huytran0605
Copy link

huytran0605 commented Aug 15, 2017

Currently, the code in server i use config like example.

app.configure(socketio(function(io) {
  io.on('connection', function(socket) {
    socket.emit('news', { text: 'A client connected!' });
    socket.on('my other event', function (data) {
      console.log(data);
    });
  });
}));

But code in client, i'm using like this:

import io from 'socket.io-client';

const socket = io('http://localhost:8080', { transports: ['websocket'], upgrade: false });

i got error like this on console

VM47643:161 WebSocket connection to 'ws://localhost:8080/socket.io/?EIO=3&transport=websocket' failed: Connection closed before receiving a handshake response

i search anything relate handshake response but i still can not connect socket.
FYI, when i directly config socketio in index.js, i can connect.

import socketio from 'socket.io';
const server = app.listen(8080);
const io = socketio(server);
server.on('listening', () =>
    logger.info(`Feathers application started on ${app.get('host')}:${port}`),
  );
@daffl
Copy link
Member

daffl commented Aug 15, 2017

I would try with the default options like

import io from 'socket.io-client';

const socket = io('http://localhost:8080');

And see if the same error happens. It also depends how the application is set up (did you configure feathers-socketio properly?).

@huytran0605
Copy link
Author

Here is error when ai use default options:

GET http://localhost:8080/socket.io/?EIO=3&transport=polling&t=LtevyLS 404 (Not Found)
Request.create @ polling-xhr.js:264
Request @ polling-xhr.js:165

XMLHttpRequest cannot load http://localhost:8080/socket.io/?EIO=3&transport=polling&t=LtevyLS. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:3000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

Default method will be long-polling and it like we call api not found

404Route: /socket.io/?EIO=3&transport=polling&t=LtevyLS - Page not found

@daffl
Copy link
Member

daffl commented Aug 17, 2017

It must be something with your setup which is much easier to investigate with a repository to reproduce the issue.

@huytran0605
Copy link
Author

Ok i will investigate more. For now, i'm using config socketIo in index.js like this

import socketio from 'socket.io';
const server = app.listen(8080);
const io = socketio(server);
server.on('listening', () =>
    logger.info(`Feathers application started on ${app.get('host')}:${port}`),
  );

@daffl daffl closed this as completed Sep 1, 2017
@Zalasanjay
Copy link

Zalasanjay commented Mar 8, 2018

i'm also facing problem like you @huytran0605
getting this error :
wss://ws.xxxxxxxx.xx:4038/socket.io/?EIO=3&transport=websocket' failed: Connection closed before receiving a handshake response

this is the code of my front-end in .vue file

import io from 'socket.io-client';
  import feathers from 'feathers/client';
  import socketio from 'feathers-socketio/client';

  var socket = io('wss://ws.xxxxxxxx:4038', { transports: ['websocket']})
  var app = feathers();
  app.configure(socketio(socket));
  var message = app.service('vshopdata');
  Vue.use(feathers);

this is the code of my back-end in app.js file

const express = require('@feathersjs/express');
const feathers = require('@feathersjs/feathers');
const socketio = require('@feathersjs/socketio');

const app = express(feathers());
app.configure(configuration(path.join(__dirname, '..')))

app.configure(socketio(4038, {
  wsEngine: 'uws',
  origin: '*.xxxxxx.xx:*'
}));

@ramsestom
Copy link

I think it is a related to a bug in the version of socket.io used by @feathersjs/socket.io that is solved with the latest version of socket.io (2.1.0): socketio/socket.io#2294
Try to update to the latest version of socket.io to see if you still have this issue

@daffl
Copy link
Member

daffl commented Apr 4, 2018

I felt it might be something like that given the amount of issues around Socket.io and timeouts recently. I'll make a new patch release that will use that version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants