NetEase / pomelo

A fast,scalable,distributed game server framework for Node.js.
http://pomelo.netease.com
MIT License
11.86k stars 2.9k forks source link

Using a different web server? #913

Open Shadowstep33 opened 7 years ago

Shadowstep33 commented 7 years ago

Hi,

I am trying to use Ionic as my web server and connect to the websocket server but am having some problems.

I have taken a lot of the code from the web-server directory of the chat client to try and get the environment as close as possible. Basically, what is happening is I am running the queryEntry function:

        function connectToGameServer(){
            var pomelo = window.pomelo;

            // query connector
            var route = 'gate.gateHandler.queryEntry';
            pomelo.init({
                host: window.location.hostname,
                port: 3014,
                log: true
            }, function() {
                console.log("Connected ",data);

                pomelo.request(route, {
                    uid: 'shadowstep'
                }, function(data) {
                    pomelo.disconnect();
                    if(data.code === 500) {
                        console.log(data);
                        return;
                    }

                    console.log("Entered ",data);
                });
            });     
        }

and the websocket connection opens but no data is ever sent or received and none of the above console logs occur so it seems like the connection is for some reason not being treated as valid. Ionic is serving files on port 8100 and I am using 127.0.0.1 but I can also use localhost if needed. My index.html dependencies looks a bit liek this:

    <script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>

    <!-- Other Libraries-->
    <script src="lib/build/build.js" type="text/javascript"></script>
    <script type="text/javascript">

     require('boot');
    </script> 
    <script src="lib/jquery/dist/jquery.js"></script>
    <script src="lib/pomeloclient.js"></script>
Shadowstep33 commented 7 years ago

Also a bit of useful info, when I use y'all web-server (express) the WS connection url looks liek this:

ws://127.0.0.1:3014/

Whereas the request from my webserver looks like this:

http://localhost:3014/socket.io/?EIO=3&transport=polling&t=LeqmsSH

Is this maybe a versioning problem with dependencies? I noticed some problems b/w express 3.x and 4.x for y'alls code when I tried to set it up elsewhere. Or maybe I should use just vanilla WS and not socket.io?

fantasyni commented 7 years ago

webserver just serves as a http server
you can use whatever you like
what matters is the client js library , like socket.io version you are using
try to check this