Answer the question
In order to leave comments, you need to log in
Can't connect to sockets?
Server part
// Express
const express = require('express');
const helmet = require('helmet');
const bodyParser = require('body-parser');
const PORTs = 8433;
// app
const app = express();
app.disable('x-powered-by');
app.set('trust proxy', 1);
app.use(helmet());
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(function(req, res, next) {
req.result = {errors: []};
next();
})
// Routes
app.use('/api', require('./routes/index'));
// Error handling
app.use(require('./controllers/error_handling'));
app.use(require('./controllers/error_404'));
// Create Server
const httpsServer = require('https').createServer(credentials, app); // https
// Socket io
const io = require('socket.io')(httpsServer, {
path: '/socket'
});
io.on('connection', socket => {
console.log('user socket connected: ', socket);
})
// Listen
httpsServer.listen(PORTs, () => console.log(`App started on port ${PORTs}`)); // https
import VueSocketIO from 'vue-socket.io'
Vue.use(new VueSocketIO({
debug: true,
connection: 'https://aaa.ru:8433',
vuex: {
store,
actionPrefix: 'SOCKET_',
mutationPrefix: 'SOCKET_'
},
options: { path: '/socket' }
}))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question