youngmonkeys / ezyfox-server

A socket server (include SSL) supports realtime application, realtime game, MMORPG, messaging, chat and streaming data with TCP, UDP and Websocket
Apache License 2.0
567 stars 98 forks source link

It is not possible to run two zones on one server with correct behaviour #121

Closed Assambra closed 1 year ago

Assambra commented 1 year ago

Describe the bug I have two Seperate Apps one for Account related things and one for Game related things. The works perfect from the IDE but not both at the same time because they use the same port. So i deploy the server created two Zones:

        <zone>
            <name>free-game-server</name>
            <config-file>free-game-server-zone-settings.xml</config-file>
            <active>true</active>
        </zone>
        <zone>
            <name>free-account-server</name>
            <config-file>free-account-server-zone-settings.xml</config-file>
            <active>true</active>
        </zone>

The client send login request to the free-game-server with the correct Zone/App to the Game Server but the ezyfox server internal routes to the false free-account-server login plugin on the other Zone/App.

To Reproduce if you want see the behaviour:

  1. Get a copy of the project https://github.com/Assambra/Free-MMORPG/releases/tag/0.10.0
  2. follow my README to create the database, mail stuff and deploy both servers into the ezyfox server
  3. Create a new Account
  4. Login (this normal should lead you to free-game-server login) and login to the Game-Server
  5. You will get some Error not authenticated, this happends because the Server use the Login from the Free-Account-Server
  6. Try to login again with User: Guest# Password: Assambra this is only allowed if the Client send Login to App/Zone free-account-server (no database login) and you see the Ezyfox server can't handle different Zones on one Server or doesnt route to the right App/Zone

Expected behavior if the client send login with Zone/App it should lead on the Server to the right App/Zone

Screenshots

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

tvd12 commented 1 year ago

@Assambra, I guess your both plugins are the same package name.

When you run ezyfox server, it will print logs like this one:

{
    "settings": {
        "nodeName": "ezyfox",
        "udp": {
            "channelPoolSize": 16,
            "address": "0.0.0.0",
            "maxRequestSize": 1024,
            "port": 2611,
            "active": true,
            "handlerThreadPoolSize": 5
        },
        "debug": true,
        "maxSessions": 999999,
        "sessionManagement": {
            "sessionMaxRequestPerSecond": {
                "action": "DROP_REQUEST",
                "value": 15
            },
            "sessionMaxIdleTime": 15000,
            "sessionMaxWaitingTimeInSecond": 15,
            "sessionMaxIdleTimeInSecond": 15,
            "sessionMaxWaitingTime": 15000
        },
        "logger": {
            "ignoredCommands": "[PONG, PING]"
        },
        "zones": {
            "size": 1,
            "zones": [{
                    "maxUsers": 999999,
                    "userManagement": {
                        "allowGuestLogin": false,
                        "userMaxIdleTime": 0,
                        "allowChangeSession": true,
                        "guestNamePrefix": "Guest#",
                        "maxSessionPerUser": 5,
                        "userMaxIdleTimeInSecond": 0,
                        "userNamePattern": "^[a-zA-Z0-9_.#]{3,64}$"
                    },
                    "streaming": {
                        "enable": false
                    },
                    "plugins": {
                        "size": 1,
                        "plugins": [{
                                "listenEvents": "[USER_LOGIN]",
                                "folder": "hello-world",
                                "threadPoolSize": 0,
                                "configFile": "",
                                "name": "hello-world",
                                "activeProfiles": null,
                                "entryLoader": "com.example.hello_world.startup.HelloWorldStartup$DecoratedPluginEntryLoader",
                                "id": 1,
                                "packageName": null,
                                "priority": 0
                            }]
                    },
                    "configFile": "",
                    "name": "example",
                    "id": 1,
                    "eventControllers": {
                        "eventControllers": []
                    },
                    "applications": {
                        "size": 1,
                        "apps": [{
                                "maxUsers": 999999,
                                "folder": "hello-world",
                                "threadPoolSize": 0,
                                "configFile": "",
                                "name": "hello-world",
                                "activeProfiles": null,
                                "entryLoader": "com.example.hello_world.startup.HelloWorldStartup$DecoratedAppEntryLoader",
                                "id": 1,
                                "packageName": null
                            }]
                    }
                }]
        },
        "eventControllers": {
            "eventControllers": [{
                    "controller": "com.example.hello_world.startup.ServerInitializingController",
                    "eventType": "SERVER_INITIALIZING"
                }, {
                    "controller": "com.example.hello_world.startup.ClientHandshakeController",
                    "eventType": "CLIENT_HANDSHAKE"
                }]
        },
        "streaming": {
            "enable": false
        },
        "threadPoolSize": {
            "extensionRequestHandler": 8,
            "socketUserRemovalHandler": 3,
            "streamHandler": 8,
            "socketDisconnectionHandler": 2,
            "socketDataReceiver": 1,
            "statistics": 1,
            "systemRequestHandler": 8
        },
        "websocket": {
            "codecCreator": "com.tvd12.ezyfox.codec.JacksonCodecCreator",
            "address": "0.0.0.0",
            "sslConfig": {
                "file": "ssl-config.properties",
                "loader": "com.tvd12.ezyfoxserver.ssl.EzySimpleSslConfigLoader",
                "contextFactoryBuilder": "com.tvd12.ezyfoxserver.ssl.EzySimpleSslContextFactoryBuilder"
            },
            "port": 2208,
            "sslActive": false,
            "active": true,
            "sslPort": 2812,
            "maxFrameSize": 2048,
            "managementEnable": false,
            "writerThreadPoolSize": 8
        },
        "socket": {
            "codecCreator": "com.tvd12.ezyfox.codec.MsgPackCodecCreator",
            "address": "0.0.0.0",
            "maxRequestSize": 512,
            "sslConnectionAcceptorThreadPoolSize": 8,
            "port": 3005,
            "sslType": "CERTIFICATION",
            "sslHandshakeTimeout": 350,
            "sslActive": true,
            "active": true,
            "connectionAcceptorThreadPoolSize": 1,
            "tcpNoDelay": false,
            "writerThreadPoolSize": 8
        },
        "admins": {
            "count": 0,
            "admins": []
        }
    },
    "version": "1.0.0",
    "config": {
        "loggerConfigFile": "default",
        "enableAppClassLoader": false,
        "ezyfoxHome": ""
    }
}

Could you give me your logs?

Assambra commented 1 year ago

ezyfox-server.log

tvd12 commented 1 year ago

@Assambra I see the both plugin free-game-server and free-account-server-plugin are using the same "entryLoader": "com.assambra.plugin.PluginEntryLoader", I think it's the issue, could you check it?

Assambra commented 1 year ago
<applications>
        <application>
            <name>free-account-server</name>
            <folder>free-account-server-app-entry</folder>
            <entry-loader>com.assambra.app.AppEntryLoader</entry-loader>
            <config-file>config/config.properties</config-file>
        </application>
    </applications>

<applications>
        <application>
            <name>free-game-server</name>
            <folder>free-game-server-app-entry</folder>
            <entry-loader>com.assambra.app.AppEntryLoader</entry-loader>
            <config-file>config/config.properties</config-file>
        </application>
    </applications>

<plugins>
        <plugin>
            <name>free-game-server</name>
            <folder>free-game-server-plugin</folder>
            <priority>-1</priority>
            <entry-loader>com.assambra.plugin.PluginEntryLoader</entry-loader>
            <config-file>config/config.properties</config-file>
            <listen-events>
                <event>USER_LOGIN</event>
                <event>USER_ADDED</event>
                <event>USER_REMOVED</event>
            </listen-events>
        </plugin>
    </plugins>`

<plugins>
        <plugin>
            <name>free-account-server</name>
            <folder>free-account-server-plugin</folder>
            <priority>-1</priority>
            <entry-loader>com.assambra.plugin.PluginEntryLoader</entry-loader>
            <config-file>config/config.properties</config-file>
            <listen-events>
                <event>USER_LOGIN</event>
                <event>USER_ADDED</event>
                <event>USER_REMOVED</event>
            </listen-events>
        </plugin>
    </plugins>
tvd12 commented 1 year ago

@Assambra you need to use difference entry-loader for plugins and apps, example:

<applications>
        <application>
            <name>free-account-server</name>
            <folder>free-account-server-app-entry</folder>
            <entry-loader>com.assambra.free_account.app.AppEntryLoader</entry-loader>
            <config-file>config/config.properties</config-file>
        </application>
    </applications>

<applications>
        <application>
            <name>free-game-server</name>
            <folder>free-game-server-app-entry</folder>
            <entry-loader>com.assambra.free_game.app.AppEntryLoader</entry-loader>
            <config-file>config/config.properties</config-file>
        </application>
    </applications>

<plugins>
        <plugin>
            <name>free-game-server</name>
            <folder>free-game-server-plugin</folder>
            <priority>-1</priority>
            <entry-loader>com.assambra.free_game.plugin.PluginEntryLoader</entry-loader>
            <config-file>config/config.properties</config-file>
            <listen-events>
                <event>USER_LOGIN</event>
                <event>USER_ADDED</event>
                <event>USER_REMOVED</event>
            </listen-events>
        </plugin>
    </plugins>`

<plugins>
        <plugin>
            <name>free-account-server</name>
            <folder>free-account-server-plugin</folder>
            <priority>-1</priority>
            <entry-loader>com.assambra.free_account.plugin.PluginEntryLoader</entry-loader>
            <config-file>config/config.properties</config-file>
            <listen-events>
                <event>USER_LOGIN</event>
                <event>USER_ADDED</event>
                <event>USER_REMOVED</event>
            </listen-events>
        </plugin>
    </plugins>
Assambra commented 1 year ago

Thank you i will try it this way

Assambra commented 1 year ago

Is there some additional steps or do i need do some refactoring/renaming now i get class not found exception see log file: ezyfox-server.log

Assambra commented 1 year ago

Ok it works as it should now i've done a lot of renaming packages and look for the correcting strings, but i think if i missed some it gives later on problems. So i copy my code later into two new projects with different packages names to be sure following problems didn't come from i missed something.

Thanks again

tvd12 commented 1 year ago

So, can I close this issue?

Assambra commented 1 year ago

Yes, thank you