Open Greg-J opened 2 years ago
Put the multi server part of the config of the two servers here, hide the ip.
And what crash is that? Any log?
"multiServer": {
"enable": true,
"host": "127.0.0.1",
"port": 5000,
"name": "Creative",
"botIds": [
"752667599162310657"
]
},
and
"multiServer": {
"enable": true,
"host": "127.0.0.1",
"port": 5000,
"name": "SMP",
"botIds": [
"752667599162310657"
]
},
are the initial setup. My modified setup is that same config sequence, but my public IP.
My main question is how do I make it work? I have a single bot (I can make more if I need too) but when I replace my hope IP with my public IP and do a /reload in chat, it crashes both servers.
You need to create Discord bot for each of the two servers.
So the multiServer
config of the two servers should be the same, only the multiServer.name
is different. Order of multiServer.botIds
does not matter.
Also, command start times between different servers should differ by at least 15 seconds.
"multiServer": {
"enable": true,
"host": "PUBLIC_IP",
"port": 5000,
"name": "NAME",
"botIds": [
"BOT_1",
"BOT_2"
]
},
You do not need to do the /reload
action, just use the public IP at all times.
Why are there multiple botIds in your example?
Also, do I need forward port 5000? If so, which physical machine do I forward it to? My servers are all behind the same IP, but on different physical machines.
Something else I have noticed is that performing a command in chat only sends that command to the last server that started. Is there no way to define which server we want to get stats for or run a console command?
I think you misunderstood what I meant. You need to create bots for each of the two servers on the Discord Application website, which means their tokens and IDs will be different. When it is a different bot, you can choose which bot to execute when inputting a command. The port is up to you, and the host is usually filled in whichever server is opened first.
I think you misunderstood what I meant. You need to create bots for each of the two servers on the Discord Application website, which means their tokens and IDs will be different. When it is a different bot, you can choose which bot to execute when inputting a command. The port is up to you, and the host is usually filled in whichever server is opened first.
Okay, so I did that and changed the PUBLIC_IP to my IP, set up new bots, etc. Set my SMP server to port 5000 and my Creative Sserver to 5001 and forwarded the ports accordingly.
I get this message any time someone sends a message from chat:
Jul 19 04:36:46 dekocraft java[6038]: [04:36:46] [JDA MainWS-ReadThread/ERROR]: One of the EventListeners had an uncaught exception
Jul 19 04:36:46 dekocraft java[6038]: java.lang.NullPointerException: Cannot invoke "net.minecraft.server.MinecraftServer.method_3760()" because "top.xujiayao.mcdiscordchat.Main.SERVER" is null
Jul 19 04:36:46 dekocraft java[6038]: at top.xujiayao.mcdiscordchat.discord.DiscordEventListener.onMessageReceived(DiscordEventListener.java:547) ~[mcdiscordchat-1_19_x-2.0.0-alpha.6-77da3d48f7deec29.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:382) ~[net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:88) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:70) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:169) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:127) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:954) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:841) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:819) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:993) [net_dv8tion_jda-5.0.0-alpha.13-dcdc6c1b3c4cb393.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385) [com_neovisionaries_nv-websocket-client-2.14-a79c76b77052a4ef.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276) [com_neovisionaries_nv-websocket-client-2.14-a79c76b77052a4ef.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996) [com_neovisionaries_nv-websocket-client-2.14-a79c76b77052a4ef.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755) [com_neovisionaries_nv-websocket-client-2.14-a79c76b77052a4ef.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108) [com_neovisionaries_nv-websocket-client-2.14-a79c76b77052a4ef.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64) [com_neovisionaries_nv-websocket-client-2.14-a79c76b77052a4ef.jar:?]
Jul 19 04:36:46 dekocraft java[6038]: at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45) [com_neovisionaries_nv-websocket-client-2.14-a79c76b77052a4ef.jar:?]
This ultimately led to the server crashing: https://mclo.gs/teoxSKk
I will clarify that if I set them both back to using localhost instead of my public ip and set the ports back to 5000 on both, then it no longer crashes.
However, while both servers send chat to Discord, only my SMP server receives messages from my Creative server. My Creative server cannot see chats from my SMP server. Despite the configs being identical except for botToken and multiServer.name being different.
All servers should set multiServer.port
to exact same. This is to set the common port for TCP connection and communication.
That exception is because someone send a message before the server fully starts, i.e. displaying 'Done' message. Known issue.
However, while both servers send chat to Discord, only my SMP server receives messages from my Creative server. My Creative server cannot see chats from my SMP server. Despite the configs being identical except for botToken and multiServer.name being different.
Try stop all servers. Then start SMP. After 15 seconds start CMP. If still cant, use /reload
on discord for both servers.
That's a negative. Setting the IP to use my public facing IP causes that crash. It doesn't matter how long we wait before sending a message.
Once I change my IP in the config to 127.0.01 it doesn't crash, but the servers won't communicate with eachother.
How about treat SMP as main server, set host in SMP as 127.0.0.1, and CMP as the IP to the SMP machine? This is my current case.
Let's say my internal IPs are 192.168.100.200 for SMP and 192.168.100.201 for CMP. You are saying I should set my config IP for SMP to 127.0.0.1 and my config IP to 192.168.100.200 CMP (which would point it to SMP) and leave both ports as 5000?
Yes
SMP config:
"multiServer": {
"enable": true,
"host": "127.0.0.1",
"port": 5000,
"name": "SMP",
"botIds": [
"998807552441721023",
"998801988781346867"
]
},
CMP config:
"multiServer": {
"enable": true,
"host": "192.168.100.200",
"port": 5000,
"name": "Creative",
"botIds": [
"998807552441721023",
"998801988781346867"
]
},
As SMP was already running with that configuration, I changed the host IP for the CMP config and restarted the Creative server.
The result is that messages sent from SMP show up in CMP, but messages from CMP do not show up in SMP.
Is there any exception logged?
There is nothing logged in the console of either server.
Can you try to execute any command for each bot? See if both servers have the "xx execute /xx command!" message.
I just tested my own server. There seems to be a similar problem, but my problem is the opposite of yours, SMP can receive CMP messages, but CMP cannot receive SMP messages. Will look into it tomorrow.
Further investigation: If I perform /info
and select my SMPBot, I get the /info from both servers. If I perform /info
and select my CreativeBot, I get only the info from the Creative server.
I test again several times with public ip used (port forwarding) today. The is no problem with the multi server feature at all.
I added some logging related to multi server. Can you try the latest build and see if there is any problem?
My config:
SMP (main)
"multiServer": {
"enable": true,
"host": "127.0.0.1",
"port": 5000,
"name": "SMP",
"botIds": [
"hidden",
"hidden"
]
},
CMP
"multiServer": {
"enable": true,
"host": "hidden.hidden.cloud",
"port": 17645,
"name": "CMP",
"botIds": [
"hidden",
"hidden"
]
},
Do you have port 5000 forwarded to your SMP server and port 17645 forwarded to your CMP server?
is hidden.hidden.cloud
your public IP, or your SMP server's internal IP?
Lastly, do you need to start/restart your servers in a specific order?
The public address hidden.hidden.cloud:17645
= smp_machine:5000
in my port forwarding case.
Need to start (/reload
) SMP first, then start (/reload
) CMP. Emmm if your machine is fast enough I think you just need to wait for around 2 seconds before starting CMP.
In my case, when CMP is started first, multi server will fail to create to create the server socket: (CMP)
...
[16:03:42] [main/INFO]: -----------------------------------------
[16:03:42] [main/INFO]: MCDiscordChat (MCDC) 2.0.0-alpha.6
[16:03:42] [main/INFO]: By Xujiayao
[16:03:42] [main/INFO]:
[16:03:42] [main/INFO]: More information + Docs:
[16:03:42] [main/INFO]: https://blog.xujiayao.top/posts/4ba0a17a/
[16:03:42] [main/INFO]: -----------------------------------------
...
[16:01:38] [Thread-9/INFO]: [MultiServer] Connected to the server
...
[16:01:41] [Thread-10/INFO]: [MultiServer] Disconnected from the server
...
[15:42:22] [Worker-Main-14/INFO]: Preparing spawn area: 0%
...
This is a normal success case: (SMP)
...
[15:41:37] [main/INFO]: -----------------------------------------
[15:41:37] [main/INFO]: MCDiscordChat (MCDC) 2.0.0-alpha.6
[15:41:37] [main/INFO]: By Xujiayao
[15:41:37] [main/INFO]:
[15:41:37] [main/INFO]: More information + Docs:
[15:41:37] [main/INFO]: https://blog.xujiayao.top/posts/4ba0a17a/
[15:41:37] [main/INFO]: -----------------------------------------
...
[15:41:39] [Thread-9/INFO]: [MultiServer] Server has been created and is listening on port 5000
...
[15:41:40] [Thread-9/INFO]: [MultiServer] Connected to the server
[15:41:40] [Thread-11/INFO]: [MultiServer] A client is connected to the server
...
[15:41:48] [Server thread/INFO]: Time elapsed: 4121 ms
[15:41:48] [Server thread/INFO]: Done (4.720s)! For help, type "help"
...
[15:42:15] [Thread-19/INFO]: [MultiServer] A client is connected to the server
[15:42:23] [Thread-12/INFO]: [CMP] **Server started!**
...
[15:43:12] [Thread-12/INFO]: [CMP] **Xujiayao joined the game**
[15:43:25] [Thread-12/INFO]: [CMP] <Xujiayao> /log tps
[15:44:16] [Thread-12/INFO]: [CMP] **Xujiayao has made the advancement [Sweet Dreams]**
[15:45:09] [Thread-12/INFO]: [CMP] **Xujiayao left the game**
...
[15:54:40] [Thread-19/INFO]: [MultiServer] A client has disconnected from the server
[15:54:40] [Thread-12/INFO]: [CMP] **Server stopped!**
...
[15:54:50] [Server thread/INFO]: Stopping the server
[15:54:50] [Thread-11/INFO]: [MultiServer] A client has disconnected from the server
[15:54:50] [Thread-12/INFO]: [MultiServer] Disconnected from the server
[15:54:50] [Thread-10/INFO]: [MultiServer] Server has stopped
[15:54:50] [Server thread/INFO]: Stopping server
[15:54:50] [Server thread/INFO]: Saving players
[15:54:50] [Server thread/INFO]: Saving worlds
[15:54:51] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[15:54:51] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
[15:54:51] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
[15:54:51] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[15:54:51] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[15:54:51] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[15:54:51] [Server thread/INFO]: ThreadedAnvilChunkStorage: All dimensions are saved
This does not work for me and I cannot for the life of me see what I'm doing differently than you. For reference, I am using MCDiscordChat-2.0.0-alpha.6.jar
SMP:
"multiServer": {
"enable": true,
"host": "127.0.0.1",
"port": 5000,
"name": "SMP",
"botIds": [
"BOT_1",
"BOT_2"
]
},
CMP:
"multiServer": {
"enable": true,
"host": "PUBLIC_IP",
"port": 5001,
"name": "Creative",
"botIds": [
"BOT_1",
"BOT_2"
]
},
I also have PUBLIC_IP:5001 forwarded to SMP:5000
I restart (or /reload) SMP and wait until it fully loads. Then I restart (or /reload) CMP and wait until it fully loads. The result is that Chat from SMP shows up in CMP, but chat from CMP does not show up in SMP.
Now, when I reload SMP I get the following in the console:
Jul 20 15:36:51 dekocraft java[10942]: [15:36:51] [Thread-706/INFO]: [MultiServer] Server has been created and is listening on port 5000
Jul 20 15:36:52 dekocraft java[10942]: [15:36:52] [Thread-706/INFO]: [MultiServer] Connected to the server
Jul 20 15:36:55 dekocraft java[10942]: [15:36:55] [Timer-14/ERROR]: Uncaught exception in thread "Timer-14"
Jul 20 15:36:55 dekocraft java[10942]: java.util.NoSuchElementException: null
Jul 20 15:36:55 dekocraft java[10942]: at java.util.HashMap$HashIterator.nextNode(HashMap.java:1599) ~[?:?]
Jul 20 15:36:55 dekocraft java[10942]: at java.util.HashMap$KeyIterator.next(HashMap.java:1620) ~[?:?]
Jul 20 15:36:55 dekocraft java[10942]: at java.util.Collections.min(Collections.java:601) ~[?:?]
Jul 20 15:36:55 dekocraft java[10942]: at top.xujiayao.mcdiscordchat.multiServer.MultiServer$1.run(MultiServer.java:113) ~[mcdiscordchat-1_19_x-2.0.0-alpha.6-77da3d48f7deec29.jar:?]
Jul 20 15:36:55 dekocraft java[10942]: at java.util.TimerThread.mainLoop(Timer.java:566) ~[?:?]
Jul 20 15:36:55 dekocraft java[10942]: at java.util.TimerThread.run(Timer.java:516) ~[?:?]
When I /reload CMP, I get the following in the console:
Jul 20 15:37:03 dekocraft2 java[20876]: [15:37:03] [Thread-43/INFO]: [MultiServer] Connected to the server
Again, messages from SMP show up in CMP, but messages from CMP do not show up in SMP.
Edit: I also want to clarify that this is the case whether I restart the servers with several minutes between starting them, or if I use the /reload command in Discord. I always get that error when starting SMP (although the number in Timer-14
changes). I do not see that error when starting CMP.
You can download the current latest build here, file name and version is the same but code inside is different from the latest release version.
My full config: (To see if there is any difference from yours) smp.txt cmp.txt You may upload your config (hide sensitive data) of both servers here for me to test.
I still cannot reproduce 'messages from SMP show up in CMP, but messages from CMP do not show up in SMP', but I did encounter similar problem when I was writing multi server code a long time ago.
That NoSuchElement exception is really weird, seems even smp itself did not react to the broadcast request of information for updating channel topic. If the same problem occurs again, please upload the full log file, thx.
My SMP server won't start with the latest version. It crashes on startup with the following error:
[20:42:29] [main/INFO]: MCDiscordChat (MCDC) 2.0.0-alpha.6
[20:42:29] [main/INFO]: By Xujiayao
[20:42:29] [main/INFO]:
[20:42:29] [main/INFO]: More information + Docs:
[20:42:29] [main/INFO]: https://blog.xujiayao.top/posts/4ba0a17a/
[20:42:29] [main/INFO]: -----------------------------------------
[20:42:30] [main/INFO]: Login Successful!
[20:42:30] [JDA MainWS-ReadThread/INFO]: Connected to WebSocket
[20:42:30] [JDA MainWS-WriteThread/ERROR]: WebSocket connection was closed and cannot be recovered due to identification issues
CloseCode(4014 / Disallowed intents. Your bot might not be eligible to request a privileged intent such as GUILD_PRESENCES, MESSAGE_CONTENT, or GUILD_MEMBERS.)
[20:42:30] [main/ERROR]: java.lang.IllegalStateException: Was shutdown trying to await status
at net.dv8tion.jda.internal.JDAImpl.awaitStatus(JDAImpl.java:493)
at net.dv8tion.jda.api.JDA.awaitStatus(JDA.java:320)
at net.dv8tion.jda.api.JDA.awaitReady(JDA.java:370)
at top.xujiayao.mcdiscordchat.Main.onInitializeServer(Main.java:83)
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47)
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke(EntrypointUtils.java:35)
at net.fabricmc.loader.impl.game.minecraft.Hooks.startServer(Hooks.java:63)
at net.minecraft.server.Main.main(Main.java:101)
at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461)
at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
at net.fabricmc.loader.impl.launch.knot.KnotServer.main(KnotServer.java:23)
at net.fabricmc.loader.impl.launch.server.FabricServerLauncher.main(FabricServerLauncher.java:69)
at net.fabricmc.installer.ServerLauncher.main(ServerLauncher.java:69)```
I've reverted back to the .jar available on Curseforge and will just live with the fact that multiserver doesn't work.
We have the same config setups and you claim we have the same port forwarding setups, so there's nothing more I can do beyond this.
The latest version requires you to MUST enable the following MESSAGE_CONTENT
intent on Discord Developer Portal. This has always been written in the docs. You probably did not set up discord bots according to the docs.
Checks
Description
There is one previous issue about this but following the instructions on it causes my servers to crash.
I updated multiServer.host to be my public IP on both servers but it did not work.
I have two servers hosted on different machines using the same public IP (different ports).
How do I get cross-server communication enabled?