Xujiayao / Discord-MC-Chat

Discord-MC-Chat (DMCC), formerly known as MC-Discord-Chat and MCDiscordChat (MCDC), is a practical and powerful Fabric and Quilt Minecraft <> Discord chat bridge inspired by BRForgers/DisFabric
https://blog.xujiayao.com/posts/4ba0a17a/
MIT License
62 stars 34 forks source link

[Question] MCDC Multi-Server Help #112

Open Maelan2 opened 1 year ago

Maelan2 commented 1 year ago

Checks

Description

Hello, What is the procedure to link 2 servers together with MCDC. Thanks in advance

Maelan2 commented 1 year ago

I'm sorry but I can't find an answer to my questions. I have two servers under velocity (so same machine).

"multiServer": { "enable": true, "host": "127.0.0.1", "port": 5000, "name": "SMP", "botIds": [] }

"multiServer": { "enable": true, "host": "127.0.0.1", "port": 5000, "name": "CMP", "botIds": [] }

But it does not work, no message from one server appears on the other.

Xujiayao commented 1 year ago

Have you created two Discord bots? One each, so the bot token of two config are different. Like this:

image

SMP

{
  "generic": {
    "botToken": "tokenA",
    "webhookUrl": "sameLink",
    "channelId": "sameChannel"
  },
  "multiServer": {
    "enable": true,
    "host": "127.0.0.1",
    "port": 5000,
    "name": "SMP",
    "botIds": [
      "tokenA",
      "tokenB"
    ]
  }

CMP

{
  "generic": {
    "botToken": "tokenB",
    "webhookUrl": "sameLink",
    "channelId": "sameChannel"
  },
  "multiServer": {
    "enable": true,
    "host": "127.0.0.1",
    "port": 5000,
    "name": "CMP",
    "botIds": [
      "tokenA",
      "tokenB"
    ]
  }

Try this setup and start one of them 10 seconds before another. If still have problem send both server logs.

OrionFE commented 1 year ago

Hi , we tried what you said and everything is working except one thing :

So we have a CMP server and a SMP server. When we type something in the chat on both server , everything is redirecte on the discord channel 💹 When we type something in the discord channel , the message is redirect on both server CMP and SMP 💹

But when i'm on the CMP server , i can't see in game the message that someone wrote in the SMP server and vise versa from SMP to CMP.

Do you know what's the problem ?

Here's the log :

[13:58:08] [main/INFO]: MCDiscordChat (MCDC) 2.1.2 [13:58:08] [main/INFO]: By Xujiayao [13:58:08] [main/INFO]: [13:58:08] [main/INFO]: More information + Docs:

[13:58:10] [main/INFO]: Login Successful! [13:58:10] [JDA MainWS-ReadThread/INFO]: Connected to WebSocket [13:58:11] [JDA MainWS-ReadThread/INFO]: Finished Loading! [13:58:11] [main/INFO]: Loading configuration... [13:58:11] [Thread-18/INFO]: [MultiServer] Server has been created and is listening on port 5000

Ty in advance

Xujiayao commented 1 year ago

So we have a CMP server and a SMP server. When we type something in the chat on both server , everything is redirecte on the discord channel 💹 When we type something in the discord channel , the message is redirect on both server CMP and SMP 💹

This works because the two Discord bots do their own job well.

But when i'm on the CMP server , i can't see in game the message that someone wrote in the SMP server and vise versa from SMP to CMP.

Which means the servers did not connect to each other. Full log of both servers?

OrionFE commented 1 year ago

Here's the full log of CMP : https://gist.github.com/OrionFE/5acce3fcf60411295f769880e7c9624c An the SMP : https://gist.github.com/OrionFE/df1dac8cae25889712d78db3b66805e7

Xujiayao commented 1 year ago

I have two servers under velocity (so same machine).

Confirm? Are the servers accessing the same 127.0.0.1? From your logs it seems that both servers created its own MCDC server on unoccupied ports 5000.

OrionFE commented 1 year ago

In the config both are one 127.0.0.1 : "multiServer": { "enable": true, "host": "127.0.0.1", "port": 5000,

But in velocity toml , both server are on 172.18.0.1 :

survival = "172.18.0.1:25565" creatif = "172.18.0.1:25566"

Xujiayao commented 1 year ago

172.18.0.1 is private IP address. Try set both MCDC config to 172.18.0.1 then?

OrionFE commented 1 year ago

When you put the 172.18.0.1 , we are getting kicked when we type something and there are error in the console :

[17:07:07] [main/INFO]: MCDiscordChat (MCDC) 2.1.2 [17:07:07] [main/INFO]: By Xujiayao [17:07:07] [main/INFO]: [17:07:07] [main/INFO]: More information + Docs:

[17:07:09] [main/INFO]: Login Successful! [17:07:09] [JDA MainWS-ReadThread/INFO]: Connected to WebSocket [17:07:10] [JDA MainWS-ReadThread/INFO]: Finished Loading! [17:07:10] [main/INFO]: Loading configuration... [17:07:10] [Thread-19/INFO]: [MultiServer] Server has been created and is listening on port 5000 [17:07:10] [main/INFO]: Loading Xaero's Minimap - Stage 1/2 (Server) [17:07:10] [main/INFO]: Loading Xaero's World Map - Stage 1/2 (Server) [17:07:10] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD' [17:07:11] [Thread-19/ERROR]: java.net.ConnectException: Connection refused at java.base/sun.nio.ch.Net.connect0(Native Method) at java.base/sun.nio.ch.Net.connect(Net.java:579) at java.base/sun.nio.ch.Net.connect(Net.java:568) at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) at java.base/java.net.Socket.connect(Socket.java:633) at java.base/java.net.Socket.connect(Socket.java:583) at java.base/java.net.Socket.(Socket.java:507) at java.base/java.net.Socket.(Socket.java:287) at top.xujiayao.mcdiscordchat.multiServer.client.Client.connect(Client.java:18) at top.xujiayao.mcdiscordchat.multiServer.MultiServer.run(MultiServer.java:37)

Xujiayao commented 1 year ago

??? Not sure how Velocity and Pterodactyl works. Try set host to localhost? And randomly change the port? (Keep both the same)

Just tested my SMP and CMP on a Windows machine, 127.0.0.1:5000 works perfectly, if still not working then I have no idea.

Maelan2 commented 1 year ago

Hello, I'm on the config with OrionFE Here is what happens when I perform a /reload of discord and that only on one of the 2 bots.

[21:09:56] [JDA MainWS-ReadThread/INFO]: [Survie] Maelan executed /reload command! [21:09:56] [Thread-148/INFO]: [MultiServer] A client has disconnected from the server [21:09:56] [Thread-147/INFO]: [MultiServer] Disconnected from the server [21:09:56] [Thread-146/INFO]: [MultiServer] Server has stopped [21:09:56] [Thread-152/INFO]: [MultiServer] Server has been created and is listening on port 25335 [21:09:57] [ForkJoinPool.commonPool-worker-5/ERROR]: RestAction queue returned failure: [ErrorResponseException] 10062: Unknown interaction net.dv8tion.jda.api.exceptions.ContextException: null at net.dv8tion.jda.api.exceptions.ContextException.here(ContextException.java:54) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.api.requests.Request.(Request.java:73) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.requests.RestActionImpl.queue(RestActionImpl.java:200) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.requests.restaction.interactions.InteractionCallbackImpl.queue(InteractionCallbackImpl.java:74) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:572) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:538) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at top.xujiayao.mcdiscordchat.discord.DiscordEventListener.onSlashCommandInteraction(DiscordEventListener.java:73) ~[mcdiscordchat-1_19_x-2.1.2-3b834a6de7ba4c61.jar:?] at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:424) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:88) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:70) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:171) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.handle.InteractionCreateHandler.handleCommand(InteractionCreateHandler.java:112) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.handle.InteractionCreateHandler.handleInternally(InteractionCreateHandler.java:83) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:39) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:984) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:870) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:848) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:1023) ~[net_dv8tion_jda-5.0.0-beta.2-187ce86b90da7eed.jar:?] at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385) ~[com_neovisionaries_nv-websocket-client-2.14-284fcff6bd34bc70.jar:?] at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276) ~[com_neovisionaries_nv-websocket-client-2.14-284fcff6bd34bc70.jar:?] at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996) ~[com_neovisionaries_nv-websocket-client-2.14-284fcff6bd34bc70.jar:?] at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755) ~[com_neovisionaries_nv-websocket-client-2.14-284fcff6bd34bc70.jar:?] at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108) ~[com_neovisionaries_nv-websocket-client-2.14-284fcff6bd34bc70.jar:?] at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64) ~[com_neovisionaries_nv-websocket-client-2.14-284fcff6bd34bc70.jar:?] at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45) ~[com_neovisionaries_nv-websocket-client-2.14-284fcff6bd34bc70.jar:?] [21:09:57] [Thread-152/INFO]: [MultiServer] Connected to the server [21:09:57] [Thread-156/INFO]: [MultiServer] A client is connected to the server

Xujiayao commented 1 year ago

Are u two for the same server?

Xujiayao commented 1 year ago

From this log the another client is still not connected to this server, the client in this log is from the server itself. What happens if you reload one server and 10 seconds after reload another server?

The exception is normal.

[21:09:56] [JDA MainWS-ReadThread/INFO]: [Survie] Maelan executed /reload command!
[21:09:56] [Thread-148/INFO]: [MultiServer] A client has disconnected from the server
[21:09:56] [Thread-147/INFO]: [MultiServer] Disconnected from the server
[21:09:56] [Thread-146/INFO]: [MultiServer] Server has stopped
[21:09:56] [Thread-152/INFO]: [MultiServer] Server has been created and is listening on port 25335
Xujiayao commented 1 year ago

You may try this simplest SMP and CMP setup, simply modify ONLY the xxxs in the config. If this works, then you may have to check the other mods or Velocity or Pterodactyl.

Test.zip