Monday, 13 March 2017

Deploying node.js + socket.io backend/server on azure

I have some trouble deploying my "Backend/Server" which is totally based on node.js and socket.io.

I am trying for 4 days (part time, afther work time) to run my server on azure web services, but without any success.

Afther some time I realized it didn't push to server correctly because I missed:

  "engines": {  
    "node": "6.10.0"  
  },

in the package.json.

Now I have the following error when running my server on web service in "D:\home\LogFiles\Application\logging-errors.txt ":

Mon Mar 13 2017 21:36:58 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
TypeError: server.listeners is not a function
    at Server.attach (D:\home\site\wwwroot\node_modules\socket.io\node_modules\engine.io\lib\server.js:424:26)
    at Function.attach (D:\home\site\wwwroot\node_modules\socket.io\node_modules\engine.io\lib\engine.io.js:124:10)
    at Server.listen.Server.attach (D:\home\site\wwwroot\node_modules\socket.io\lib\index.js:240:21)
    at new Server (D:\home\site\wwwroot\node_modules\socket.io\lib\index.js:52:17)
    at Server (D:\home\site\wwwroot\node_modules\socket.io\lib\index.js:40:41)
    at Object.<anonymous> (D:\home\site\wwwroot\server.js:1:92)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)

This is my server side code(the beginning of it):

var io = require('socket.io')(process.env.PORT || 3000);
var AI = require('./AI');
var gamelogic = require('./gamelogic');
var shortid = require('shortid');
var mongoose = require('mongoose');
mongoose.Promise = require('bluebird');

io.on('connection', function(socket){
        socket.emit("Testing");

And at the client side(C#, with a module for socket.io):

socket.On ("Testing", Test);

public void Test(SocketIOEvent e)
{
    Debug.Log ("Server is running and communicating");

}

This is my connection string to the server:

ws://MyAppname.azurewebsites.net:3000/socket.io/?EIO=4&transport=websocket

What am I doing guys? Can somebody help me with this problem?

The game will be played on android phone, I made the game with unity game engine.

Ow btw, when I am running the server locally, it runs perfectly! Multiple instances connect to the server and join rooms, ai is playing, scores is updating etc. But I can't let it communicate/run it at the server side.



via Suat Alkan

No comments:

Post a Comment