lvarayut / relay-fullstack

:point_up::running: Modern Relay Starter Kit - Integrated with Relay, GraphQL, Express, ES6/ES7, JSX, Webpack, Babel, Material Design Lite, and PostCSS
https://lvarayut.github.io/relay-fullstack/
MIT License
985 stars 126 forks source link

Question - Integrating Socket.io #83

Closed BlakeBrown closed 7 years ago

BlakeBrown commented 7 years ago

Just curious how to go about integrating socket.io into this stack?

Socket.io docs say to use:

var app = require('express')();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
io.on('connection', function(){ /* … */ });
server.listen(3000);

However, passing relayServer fails since it's a WebpackDevServer. Not sure how to resolve this while keeping HMR functional.

lvarayut commented 7 years ago

It's a long time that I don't touch Socket.io. I'm not quite sure if I could help here. Could you take a look on https://github.com/webpack/webpack-dev-server/issues/76 and https://stackoverflow.com/questions/33584724/how-to-use-socket-io-together-with-webpack-hot-middleware?

Neitsch commented 7 years ago

For dev you will have to proxy webpack dev server (https://github.com/webpack/webpack-dev-server/issues/283#issuecomment-162163329). For prod you will need to proxy via express (https://github.com/chimurai/http-proxy-middleware/blob/master/examples/websocket/index.js).

Please close unless you need any more help 😄

BlakeBrown commented 7 years ago

Thank you guys! I think that's enough to get me started :)

Feel free to close the issue!