I'm trying to implement my Socketcluster server. However when visiting the page the development server of Nuxt crashes.
nuxt:render Rendering url / +0ms
nuxt:render Data fetching /: 10ms +0ms
/home/maarten/Programming/Production/totalfreedom/client/node_modules/socketcluster-client/lib/scclientsocket.js:544
throw err;
^
SocketProtocolError: Socket hung up
at SCClientSocket._onSCClose (/home/maarten/Programming/Production/totalfreedom/client/node_modules/socketcluster-client
/lib/scclientsocket.js:647:15)
at SCTransport.<anonymous> (/home/maarten/Programming/Production/totalfreedom/client/node_modules/socketcluster-client/lib/scclientsocket.js:297:12)
at SCTransport.Emitter.emit (/home/maarten/Programming/Production/totalfreedom/client/node_modules/component-emitter/index.js:133:20)
at SCTransport._onClose (/home/maarten/Programming/Production/totalfreedom/client/node_modules/socketcluster-client/lib/sctransport.js:217:28)
at WebSocket.SCTransport.wsSocket.onerror (/home/maarten/Programming/Production/totalfreedom/client/node_modules/socketcluster-client/lib/sctransport.js:81:12)
at WebSocket.onError (/home/maarten/Programming/Production/totalfreedom/client/node_modules/socketcluster-client/node_modules/ws/lib/event-target.js:128:16)
at WebSocket.emit (events.js:182:13)
at ClientRequest.req.on (/home/maarten/Programming/Production/totalfreedom/client/node_modules/socketcluster-client/node_modules/ws/lib/websocket.js:535:10)
at ClientRequest.emit (events.js:182:13)
at Socket.socketErrorListener (_http_client.js:375:9)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@1.0.0 dev: `nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/maarten/.npm/_logs/2018-05-12T09_19_11_443Z-debug.log
I made the Socketcluster client plugin myself:
import Vue from 'vue'
import scc from 'socketcluster-client'
const SCPlugin = {
install(Vue, options) {
Vue.prototype.$sc = scc.create(options)
Vue.mixin({
mounted() {
console.log('sc plugin mounted')
}
})
}
}
const options = {
hostname: 'localhost',
secure: false,
port: 8000
}
export default () => {
Vue.use(SCPlugin, {
options
})
}
and injected it to the nuxt.config.js
plugins: [
'@/plugins/socketcluster.js'
],
I'm fairly new to Nuxt. Therefore I don't really understand where the issue might lay. In regular Vue development this works.
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c7067">#c7067</a>)</em></sub></div>