Skip to content
← Back to Community
How do I make a P2P server on repl.it?
Profile icon
tallphin

Hey! I'm trying to implement 2-player multiplayer in my game, and I'm using PeerJS for Peer-To-Peer Connection. I've got everything working, except making the server. For now, just to test, I'm using the default server that my game engine offers, but I want to make my own. I'm aware of how I can make a server on my computer (peerjs --port <insert port here> --key peerjs --path /myapp), but that won't stay on 24/7. Could someone help? Thanks!

Voters
Profile icon
tallphin
Comments
hotnewtop
Profile icon
LukaSanarski1

Hello, did you solve that problem? Can you please help me too?

Profile icon
[deleted]

You don't need a peer server and im not sure if it even works since replit only supports TCP/IP servers on port 80. It will automatically connect to peerJS free server if you only don't specify a server: https://peerjs.com/peerserver.html

Profile icon
tallphin

"what" will automatically connect to a PeerJS free server @behavingEffort?

Profile icon
gibbsfreenergy

The port should be 8.0.8.0.

Profile icon
tallphin

@JosephSanthosh, what are you talking about?

Profile icon
gibbsfreenergy

Before you edited your description of problem above, the port was wrong, the correct one is 8.0.8.0 if you're using repl.it! @GoldenFox5313

Profile icon
tallphin

Oh. I copy/pasted it from PeerJS' page, and I realised just now! @JosephSanthosh. But how am I supposed to do it?

Profile icon
gibbsfreenergy

@GoldenFox5313 I do python not js, not yet at least. I'm so sorry, maybe @abhaybhat can help you.

Profile icon
gibbsfreenergy

Sry I meant @EpicGamer007, could you help @GoldenFox5313 with this issue?

Profile icon
tallphin

Alright, @JosephSanthosh. Thanks!

Profile icon
SixBeeps

@JosephSanthosh Bruh 8.0.8.0 is not a port, that's an IP, and that's the wrong IP.

Profile icon
EpicGamer007

@GoldenFox5313 , ok, tbh i am really bad at js, but i will give you my idea. If you want to keep a server running, make it a web server and ping it.. i dont think i can help much with this sorry :(

Profile icon
tallphin

Ok, I will try that. Thanks! @EpicGamer007

Profile icon
EpicGamer007

@GoldenFox5313 , i suggest waiting a bit more and asking more people on the repl discord, I am not someone who can help very well. If you want I can post it for you

Profile icon
tallphin

Ok, I'll definitely check that out @EpicGamer007. I just got an idea from what you said earlier, so I'm trying it out right now.

Profile icon
[deleted]

@JosephSanthosh i think you mean the port 8080