No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Using socket in dev mode

    Help
    2
    4
    952
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      vasilyman last edited by

      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
      
      1 Reply Last reply Reply Quote 0
      • V
        vasilyman last edited by

        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)
          })
        }
        
        1 Reply Last reply Reply Quote 0
        • metalsadman
          metalsadman last edited by metalsadman

          @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.

          V 1 Reply Last reply Reply Quote 0
          • V
            vasilyman @metalsadman last edited by

            @metalsadman yes, i was try to search by this forum, but i find about only client socket info.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post