помогите подлючить веб сокет к ssl
Есть код Js вот он
var scribe = require('scribe-js')(), app = require('express')(), server = require('http').Server(app), io = require('socket.io')(server), requestify = require('requestify'); var schedule = require('node-schedule'); server.listen(8080); add_online(); setInterval(add_online, 60000); activebots(); io.sockets.on('connection', function (socket) { updateOnline(); getDrops(); socket.on('newDrop', function(id){ requestify.post('http://localhost/api/getGame', { id: id}) .then(function (response) { data = JSON.parse(response.body); io.sockets.emit('nd', data.text); }, function (err) { console.log(err); }); }); socket.on('disconnect', function () { updateOnline(); }); }); function updateOnline(){ io.sockets.emit('updateonline', Number(Object.keys(io.sockets.adapter.rooms).lengt h) + Number(global.online)); console.info('Connected ' + Object.keys(io.sockets.adapter.rooms).length + ' clients'); } function getDrops(){ requestify.post('http://localhost/api/getdrops', {}) .then(function (response) { data = JSON.parse(response.body); io.emit('welcomedrop', data.text); console.log("stats"); }, function (err) { console.log(err); }); }; function activebots() { console.log("\x1b[32m", "[NVBOT] Функция ботов сработала!"); requestify.post('http://localhost/api/playbot', {}) .then(function (response) { data = JSON.parse(response.body); var time = data.time; console.log("\x1b[32m", "[NVBOT] Фейк-Игра сыграна! ID: "+data.game+" Время: "+ Number(data.time)+"мс"); requestify.post('http://localhost/api/getGame', { id: data.game}) .then(function (response) { data = JSON.parse(response.body); io.sockets.emit('nd', data.text); setTimeout(function() { activebots(); }, time); }, function (err) { console.log(err); setTimeout(activebots, 50000); }); }, function (err) { console.log("\x1b[31m", "[NVBOT] Ошибка запроса"); setTimeout(activebots, 50000); }); } function add_online() { requestify.post('http://localhost/api/getonline', {}) .then(function (response) { data = JSON.parse(response.body); global.online = data.online; console.log("\x1b[32m", "[NVBOT] Фейк онлайн обновлен! (+" + data.online + ")"); updateOnline(); }, function (err) { console.log("\x1b[31m", "[NVBOT] Ошибка получения фейкового онлайна"); }); } А вот INDEX.PHP <script src="./files/socket.io-1.4.5.js"></script> <script> var socket = io.connect(':8080', {rememberTransport: false}); socket.on('welcomedrop', function(data){ $("#response").prepend(data); //$("#oe").html(kk.count); $('#response').children().slice(20).remove(); }); socket.on('updateonline', function(data){ $("#oe").html(data); }); socket.on('nd', function(data){ $("#response").prepend(data); $('#response').children().slice(20).remove(); }); </script> <script> $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); $(function() { window.history.replaceState(null, null, window.location.pathname); // getContent(); /* var conn1 = new WebSocket('ws://82.146.44.43:5858'); conn1.onmessage = function(e) { var kk = JSON.parse(e.data); $("#response").prepend(kk.new); $("#oe").html(kk.count); $('#response').children().slice(20).remove(); }; var conn2 = new WebSocket('ws://82.146.44.43:8081'); conn2.onmessage = function(e) { var kk = JSON.parse(e.data); Вот это все сейчас работает без сертификата, как вот это переключить на SSL понятия не имею сайт стоит на Ubuntu 14.04X64 |
есть вот подобная тема https://v-h.su/threads/nodejs-https.21975/ но я там не разобрался Месяц вожусь не могу сайт перевести на ssl из за этого бота((
|
Часовой пояс GMT +3, время: 09:55. |