LLAPI Does Not Work on Two Computers on Same LAN Segment?

Hi,

I’m sorry to trouble this forum; however, after reading the Unity LLAPI (Transport Layer API, seems like it should be called the TLAPI, since it is TLAPI, not LLAPI, right? LOL), and watching a handful of “LLAPI” YT videos, I cannot get Unity LLAPI (TLAPI) to work on two computers on the same LAN segment.

Also, being a client/server programmer “way back when” using C on UNIX and Linux, I do not understand why Unity calls the NetworkTransport.AddHost() method “AddHost()” and it is just creating a socket, and I assume binding the socket to the program. Seems like Unity should rename this “NetworkTransport.CreateAndBindSocket()” but I guess that is another story and helps explain why LLAPI and other UNET scripting is so difficult for programmers accustomed to real client/server code?

Anyway, sorry to ramble, but I cannot get Unity LLAPI (TLAPI) to work on two machines on the same network. My code works fine when the client and server are on the same machine; but if I move the client and server to different machines (changing the IP address of the server and server port in the client of course), it does not work.

I keep searching the net for examples of this working with two machines on the same LAN segment (or across the Internet) and I cannot find any working example or tutorial.

Does this mean that the LLAPI (actually is it the T ransport L ayer API right? LOL… nothing to do with the Link Layer… huh) does not work?

It seems if it worked, there would be many examples of working TLAPI client/server code for Unity on the net, but there is nothing that works unless the example or code is on the same box.

What gives?

Every once in a while I see a thread about this. It works for the same computer, or different computers. All of the examples show localhost or 127.0.0.1 because it’s easy, I assume. :slight_smile:
Plus, putting some other IP address in there wouldn’t really be helpful.

Beyond changing the server IP, the only thing that really matters is making sure your ports are forwarded (and maybe your firewall, if it’s not notifying your automatically).

I started in Linux and c, also. Love that stuff. :slight_smile:
I have created a small working LLAPI and HLAPI program(s) from unity before, though.

@methos5k

LOL, yeah, I already checked into all that. My local LAN is WIFI configured as a standard AP, and there is no problem to ping or connect to any other computers on the LAN. Here is my arp -an output, for example:

Tims-MacBook-Air-2:~ Tim$ arp -an
? (192.168.2.1) at 0:c0:ca:81:55:f7 on en0 ifscope [ethernet]
? (192.168.2.104) at 44:2a:60:fc:9:6c on en0 ifscope [ethernet]
? (192.168.2.108) at b8:e8:56:6:8:fa on en0 ifscope permanent [ethernet]

and I checked the WIFI AP, and there is no access control on or any port forwarding required (or even available) because the WIFI LAN is acting like a single LAN segment, as it should and it is not routing or switching, just repeating like a 802.11 (n) hub device should do.

My Unity LLAPI (TLAPI) client server code works fine on a single computers (either the 104 or 108 MacBooks in the arp output), but if I sync the scripts, and then turn off the Server game object on the client and then change the connection IP to be the server on the other machine, basic client/server 101 stuff), the Debug.Log()s show it connecting, but it is not really connected because it will not send from client to server.

Really odd about LLAPI (actually TLAPI, LOL), is that if I tell it to connect to any IP address, even to a non-existent socket, it succeeds without error in TLAPI (LLAPI) but of course there is no IP address to bind, so it’s just bogus.

I don’t think it works, really; and when I search the network there are countless others who have the same problem and some even think it is Unity’s way of crippling the LLAPI. I have no idea or what is the motive of Unity or the problem, but client / server at the LLAPI level is really common, and if it worked then there would be many people on the net and on YT with working code; but I cannot find one example of it working and I cannot get it to work.

LOL, after all, if Unity understand networking they would not call creating a socket “NetworkTransport.AddHost()” and they would have written the networking code like all other client-server code… create socket, bind socket, etc.

I think people who say “just change the IP address and it works” are people who have never coded it, LOL because it does not work, LOL

You’re probably encountering software firewall issues, as connecting client/server on the same computer is functionally the same as connecting between two different computers with Unet (LLAPI or HLAPI).

Nope. There is no firewall and no access control between the two LAN devices and I can ping the ports on both machines.

Many people on the net and in many forums have reported the same problem over many years and in each case, we cannot find a single proven code example of the LLAPI working on two different computers on the same LAN.

If it worked, then there would be myriad working examples on the net and on YT, because in real life, everyone who codes client-server applications debugs on two computers and not on the same one.

Many people on the net have opined that UNET has intentionally crippled this so as to get as ,any people as possible to use their multiplayer backend for commercial reasons.

The same seems to hold true with creating client-server within Unity with lower level C# namespaces. When we try this, the Unity C# code specifies that those lower level C# networking functions are not available in Unity.

Their seems only one logical reason for this. Unity wants to make it as difficult as possible for developers to build client-server applications and other multiplayer gaming capabilities independent of Unity multiplayer services. Otherwise, it would be a piece of cake to do this kind of basic client-server networking (between any two or more computers anywhere on the net) in Unity and the Unity Game Developers Metaverse would be full of working examples.

We have found zero working examples in the UGDM :slight_smile:

Saying it works or should work is not the same as building working code that works; and there is zero working code on the net that we can find or any any YT or other tutorials. In fact, the Metaverse of Unity developers is full of people who say Unity has intentionally crippled networking. I did not believe it at first; but I am starting to b e l i e v e… woooooooo

If skeptical… Google “getting Unity LLAPI to work on two computers” or something similar and there is a lot of folks posting how UNET is crippled or broken; and all the working examples are just like the code I created, it works fine as long as it is on a single computer, with one running as a build and the other in the editor, or something similar on one computer (multiple builds on the same box).

:frowning:

OK… after debugging this with Debug.Log() and (NetworkError)error messages at every step in the Unity LLAPI client / server process, it seems that the problem that is causing everyone so much pain in LLAPI client/server is rooted in the connectionIDs.

When running LLAPI client/server on a single machine, there seems to be no issues with connectionIDs; but then I move the client to another machine, it appears that the client connectionIDs are out of sync and that these connectionIDs must be unique across the LLAPI. (This is not documented in the Unity Networking LLAPI docs that I can tell).

For example, the connectionID created when a client connects to the server for the first time might be an int 1 in the client; however, this connectionID (the received connectionID) could be an int 3 in the server. When I try to send to the connectionID of 1 on the client, I get an error that the connectionID is wrong; but that is the connectionID assigned by the client with NetworkTransport.Connect() on the client side, however on the server side, using method NetworkTransport.Receive(), the received connectionID of the client is different than the same connectionID on the client side.

On quick Google search and attack, there are some discussions here and there about syncing connectionIDs, but I’ve got to take a break after pull a lot of hair out today.

Will post back if I can fix this and explain what needs to happen if indeed this is the issue that has been cause many o the net difficulties (including me). Still debugging…

EDIT: Nah… that does not seem to fix the problem… Darn!

Well, you don’t really need to sync the ids. At least you found that it’s working, I think? That’s good…

Also note that you can use Sockets directly in Unity, as well. I understand that you’re frustrated, but claiming there is a conspiracy about using networking is not going to help you solve your issues.

Anyways, good luck… hope you get it working. :slight_smile:

Hey @methos5k

I am not yet claiming a Unity business model to cripple networking. I am simply repeating the vast amount of similar posts on the net when others cannot get Unity networking to work and the fact that there are no working examples on the net of LLAPI working on two different computers; but there are myriad posts and examples of this not working. UNET also has this problem and NetworkDiscovery() does not work well.

And no, it’s not working … and no we have seen no working code from Unity or on the net that LLAPI works in a true client / server configuration and there are no working examples on the net, as I said. If you have working code for this, please share, or otherwise, try not to be too aggressive in defending something that works when you don’t have working code examples.

I simply pointed out in my last post that I debugged and found a Unity NetworkError “WrongConnection” but have not figured out why since this is a very simple int to set in a script.

Yes, I agree that there should be no reason to sync connectionIDs between the client and the server. The connectionIDs of the server should be completely different than the internal connectionIDs of the clients.

However, regarding the Unity business model, I do agree with myriad developer posts that Unity does try to get people to use their multiplayer networking services, because they make money off of that. It’s perfectly normal in the pursuit of money and business profits in these kinds of systems, the system owners make it difficult to use the same technology if they do not use their services. We both can name countless examples of this in practice.

This is not a “conspiracy” per se it is simply business. If “business practices” are “conspiracies” then MacDonalds conspires to make people fat for having delicious juicy burgers, LOL

It is pretty obvious that Unity wants to make money from their multiplayer services, selling CCU; and if developers had easy Unity networking available, well documented and created for ease of use, then Unity would sell less multiplayer CCUs. This is not a conspiracy, it’s business.

There are many Unity developers on the Internet and many very good developers who believe that Unity Networking is crippled , perhaps to support Unity’s business model. I do not have a full opinion on that yet, but I’m not inclined to be like many some developers and agree it is no secret that LLAPI and Unity Networking in general is poorly written and even more poorly documented.

PS: Regarding my attitude, I understand. I wrote my first client/server code in 1988 on a production line in Chicago using HPUX RMB, which HP says I was the first do ever get their client/server API to work with RMB, at the time. Now it is 30 years later, so I do have an opinion about Unity’s network API and documentation, sorry for that. I do not suffer fools easily, especially after too many years in hands on IT client/server. I am not impressed with Unity’s networking API.

Well, you did say :

Which, in my experience, isn’t true.

Besides that, I have written working code before. I no longer have a copy, though.

Perhaps you can/should post your code for some feedback. Perhaps this is an acceptable time to cross-post your question in the networking/multiplayer forum, as well (at least the code/question portion).

Hey @methos5k

Thanks for your patience and collaborative replies. I am flying 1/2 around the world tomorrow and will be on vacation for a month away from my 34" gaming monitor and hence my easy-on-the-eyes development and coding environment.

Honestly, I have little experience in posting questions about C# and Unity; and when I started developing in the Unity environment, I did not ask any questions in any forum; just watched a lot of tutorials and of course read a lot of posts, books, docs and sample code each step of the way, and am very grateful to all Unity developers who share their knowledge.

Full Disclosure:

Following the work and YT tutorials of many amazing Unity developers, I was able to create the first phase of a cybersecurity visualization application, which was featured on ResearchGate last year:

Cybersecurity experts team up on ResearchGate to make threats in cyberspace easier to see

I just checked (for full disclosure) the C# files I wrote in this Unity project (cat *cs | wc -l), I have written 7,136 lines of Unity C# code (working code), which of course does not include all the lines which made it to the trash heap, LOL That 7K number does not include C# code from imported or third party C# scripts.

After talking some time off coding this and working on other projects, frustrated because the folks who promised to code the cybersecurity virtualization app with me could not get past the Unity learning curve to contribute (in all fairness he had a full time job and did not have the time to devote to Unity/C#), I decided to pick this app up again and get the networking part working, since I had the basics done (see RG link above).

I have tried C# Sockets, UNET, LLAPI (TLAPI) and PUN and all of them have issues, or perhaps I am the one with issues, LOL; but after being frustrated with UNET and finding PUN too poorly documented; decided to turn to LLAPI because Unity did not support some of the C# .NET Networking namespaces I wanted to use for debugging and UNET had the same problem of working well on a single machine, but breaking when I moved to two machines on the same LAN. Of course, I Googled and YT’ed to death, LOL and tried many different approaches, and all had the same issue when I move from a single machine to two machines ; and the issue was not related to firewalls, access control, being stupid (well, that’s debatable, LOL) and using localhost when I should be using the IP and all the other myriad issues we find in the metaverse about these typical Unity networking problems.

I was hoping to get this basic networking on Unity going and what I though was “simple client/server Unity networking” going before leaving to the US on vacation, but such is life, LOL

When I’m back in June, I’ll decide if I should give PUN another try, or maybe try Bolt; or maybe I’ll follow your suggestion and post the code here. Honestly, I have read a lot about Unity Networking problems in many forums and other places and am now a bit discouraged over Unity networking based on both what I have read and what I have experienced (but this feeling will fade soon enough) and what I am working on is not what someone might typically call a “game” so the requirements are different; since I am building a collaborative, virtualized environment for working in near real time cyberspace.

… and I am doing it all “to make the world a better, safer place” not to sell a million games, start a new fan club and get a hot car (a side joke from the Masters of Doom book). I have hot car German sports car already and don’t even drive it, LOL

Cheers.