Using socket in dev mode
-
I connect express-ws lib via src-ssr/extention.js file. In production mode socket server will work, but in development more i can’t connect to socket, and i have error:
WebSocket connection to 'ws://localhost:3004/sockjs-node/696/0pwviygm/websocket' failed: WebSocket is closed before the connection is established.
and
WebSocket connection to 'ws://localhost:3004/' failed: Connection closed before receiving a handshake response
-
this is my src-ssr/extention.js file
module.exports.extendApp = function ({ app, ssr }) { /* Extend the parts of the express app that you want to use with development server too. Example: app.use(), app.get() etc */ const expressWs = require('express-ws')(app) app.ws('/', function(ws, req) { ws.on('message', function(msg) { console.log(msg) }) console.log('socket', req.testing) }) }
-
@vasilyman do it in a boot file https://quasar.dev/quasar-cli/cli-documentation/boot-files#Introduction https://quasar.dev/quasar-cli/developing-ssr/configuring-ssr#Boot-Files and prolly use the forum search function for websockets , there were past topics about it here, it might give you some hints.
-
@metalsadman yes, i was try to search by this forum, but i find about only client socket info.