Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

wsPort & port #23

Closed
applerao opened this issue Nov 27, 2012 · 10 comments
Closed

wsPort & port #23

applerao opened this issue Nov 27, 2012 · 10 comments

Comments

@applerao
Copy link

I error configure the chat server with a wsport, and the request to chat server can't be accessed.
I thought the wsPort is used for outside access like clients and html pages, the port is used for communication between servers. But I don't know am I right? And the real reason of my error configuration.

@changchang
Copy link
Contributor

Yeah, the wsPort means websocket port which communicates with the client and the port is used for rpc between servers.

And the html pages contents located in web server. You have to start the web server to access the web pages. And the start point of the web server is web-server/app.js.

More details of your access fail error or configure file may be helpful to locate the problem. :)

@applerao
Copy link
Author

I removed the wsport configuration of chat server in the config/servers.json, and everything works fine.
From:

"chat": [
                {"id": "chat-server-1", "host": "127.0.0.1", "port": 6150, "wsPort":6010},
                {"id": "chat-server-2", "host": "127.0.0.1", "port": 6151, "wsPort":6011},
                {"id": "chat-server-3", "host": "127.0.0.1", "port": 6152, "wsPort":6012}
        ]

To:

"chat": [
                {"id": "chat-server-1", "host": "127.0.0.1", "port": 6150},
                {"id": "chat-server-2", "host": "127.0.0.1", "port": 6151},
                {"id": "chat-server-3", "host": "127.0.0.1", "port": 6152}
        ]

If I error configure with a wsPort, the request to chat server

pomelo.request('chat.chatHandler.getUsers',..)

will results an error at file '/game-server/node_modules/pomelo/lib/server/server.js' Line 182,

var doForward = function(app, msg, session, routeRecord, cb) {
    var finished = false;
    //should route to other servers
    try {
        app.sysrpc[routeRecord.serverType].msgRemote.forwardMessage(

where the msgRemote will be 'undefined' and the serverType is 'chat'.

@applerao applerao reopened this Nov 28, 2012
@changchang
Copy link
Contributor

If you configure a server with a wsPort that means the server is a frontend server.

The frontend server has the ability of receiving the client requests from websocket and the backend server has the ability to receive requests from frontend server.

So when you add a wsPort to the chat server, then it becomes a frontend server and it loses the ability to receive requests from frontend server (the msgRemote ). So when connector(frontend server in chatofpomelo) try to forward the 'chat.chatHandler.getUsers' to chat server, it fails.

@applerao
Copy link
Author

If so, then the configuration of connector servers don't need the port configuration at all.

"connector":[
             {"id":"connector-server-1", "host":"127.0.0.1", "port":4050, "wsPort":3050},
             {"id":"connector-server-2", "host":"127.0.0.1", "port":4051, "wsPort":3051},
             {"id":"connector-server-3", "host":"127.0.0.1", "port":4052, "wsPort":3052}
         ]

@xiecc
Copy link
Collaborator

xiecc commented Nov 29, 2012

Connector server is frontend server. It needs the ability of receiving client requests.

@changchang
Copy link
Contributor

The port is the ability to receiving rpc requests and the connector has to provide rpc services such as channel push and so on. So the port is necessary for connector.

@applerao
Copy link
Author

wsPort is used to receive client requests, not port.

@changchang
Copy link
Contributor

The wsPort provides the communication between client and server known as handler while the port provides the communication between servers known as remote.

@applerao
Copy link
Author

I finally totally understand.

  1. wsPort is used for web socket communication between clients and frontend servers.
  2. wsPort disabled the ability to be called by remote rpc.
  3. port is used for remote rpc call between servers.
  4. port enable the ability call and be called by remote rpc.
    so, both configure the wsPort and port enables communicate with clients, call remote rpc to servers , but can't be called by remote rpc.

@changchang
Copy link
Contributor

Yeah, some details in picture:

client --1--> frontend server --2--> backend server

assume request transfer from client to frontend server and then to backend server.
if wsPort specified, turn on the ability of 1 and turn off 2 whereas if wsPort not specified, then turn off the ability of 1 and turn on 2.

And port is the ability of rpc between servers which has nothing to do with client request:
server <----> server

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants