• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

SOLVED GMS1.4 - How does exactly "network_connect" fails? (-1), it connects and disconnects to the server

Khyze

Member
1AM here, but I finally solved it, not sure how to explain it with words, but it seems the problem was because I was still sending packs/buffers to the previously used port, I made two locks to avoid sending them and it works perfect now, it is a placeholder base that I'm planning to copy to my main project, so I forgot to add few apparently important stuff. (it was in it, but I got confused with the id and sockets, so I stopped using the socket async, I kinda learned what I was missing, or well, remembering)

https://manual.yoyogames.com/GameMaker_Language/GML_Reference/Networking/network_connect.htm
I once did a complex network game with a couple of devs (well, only one is worth mentioning) it was made in a pre Studio way, so I learned and changed everything to Studio's Network system, all right, that was years ago, now today (and few days ago) I ran into an annoying problem.
It is weird, I set up broadcasting for LAN and everything works perfect at first sight, I have the select Server or Client option, I pick the Server, then I open the game two times again and pick them as Client, everything smooth, no errors, no issues.


Thats until I close one of the Clients and open another one, "network_connect" throws a bunch of "-1" (failed), I tried an "autoreconnect" on key press and it eventually randomly accepts the connection, but why? It is a clean new project, I tried to export/import just in case but no luck, the weirdest part of it is that if you close all the clients, the first one you try to connect doesn't has the same problem (it does connect, if one is in the autoreconnect thing, when I close the last connected client, it connects normally)

To check if it was a bug on GMS1.49999 I checked the NetworkExample from Yoyo and you can close/open as much clients as you want, I checked the code and doesn't have any extra configurations (unless I missed something outside GML) I even used the same ports for the server and broadcast server to see if I was using bad ones, I tried cross platform with one Android and same issue.

I feel like trash, I wasted 12 hours today (yeah, almost the whole freaking day trying to make this work but it just doesn't, it should...) I'm even thinking on working on top of the NetworkExample to see if it works...

A new update after the Reddit post is that the server does get the connection but it seems like it denies it?
  • Client(1) Connected: 127.0.0.1 (First client, perfect)
  • Client(2) Connected: 127.0.0.1 (Second client, perfect)
  • Client(2) Disconnected: 127.0.0.1 (Closing second client, this is when the problems start)
  • Client(2) Connected: 127.0.0.1 (I try to get a second client again but...)
  • Client(2) Disconnected: 127.0.0.1 (just after seeing the connected log, it shows this disconnected too)
  • Client(1) Disconnected: 127.0.0.1 (But if I close all the clients)
  • Client(1) Connected: 127.0.0.1 (I can open a new one)
  • Client(2) Connected: 127.0.0.1 (But only one)
  • Client(2) Disconnected: 127.0.0.1 (unless I restart the server, but it will be the same again)
The issue starts on disconnecting, I can connect more clients until I disconnect one:
  • Client(1) Connected: 127.0.0.1
  • Client(2) Connected: 127.0.0.1
  • Client(3) Connected: 127.0.0.1
  • Client(4) Connected: 127.0.0.1
  • Client(5) Connected: 127.0.0.1
  • Client(5) Disconnected: 127.0.0.1
  • Client(5) Connected: 127.0.0.1
  • Client(5) Disconnected: 127.0.0.1
https://www.reddit.com/r/gamemaker/comments/puxpe2
 
Last edited:
Top