Xcode unity build throwing error not present on other platforms?

Hi all,

I’m trying to figure this one out, but I’m not seeing something. We’re using the 2.1.0 unity package (we started development about a year ago and haven’t wanted to necessarily retool to the newer package using actions in lieu of events), and we’re hitting this wall when we run our iOS build, related to the vtortola.websockets package:

**An error occurred connecting the socket; message: vtortola.WebSockets.WebSocketException: An unknown error occurred while connection to 'ws://134.209.57.66:7350/ws?lang=en&status=False&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzk0NjE0NzAsInVpZCI6IjM3NWE2MDI5LTk4ZDQtNDE3NS1iYTIwLTVjZGM1MTlmMGE4ZSIsInVzbiI6IllLV29Id01XbFMifQ.LmHex5kTyz2IGSRQ_86kPmVhVzQ4K-Ftc6A1GbdBXq4'. More detailed information in inner exception. ---> System.TypeInitializationException: The type initializer for 'vtortola.WebSockets.Http.Headers<vtortola.WebSockets.Http.RequestHeader>' threw an exception. ---> System.TypeInitializationException: The type initializer for 'vtortola.WebSockets.Tools.EnumHelper<vtortola.WebSockets.Http.RequestHeader>' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.**

Odd thing: this only shows up in the Xcode build – PC and Android had no problems.

Any thoughts?

Best,

Sean

Hi Sean - This issue is resolved in later versions of the client. Please update to v2.3.1 of the client SDK.

Alright, any word on what the problem was that’s causing it?

I am facing the same problem, it would be nice to know what is causing it because maybe I can work it out without re-writing all the working code I have

@Steffano @Chance6Sean It’s caused by the way the low level HTTP adapter did lazy initialization which was not executed by the code generated and compiled for Unity in iOS the same way as on other platforms.

The 2.1.0 release of the Unity client sdk is almost 18 months old. We recommend you follow the releases with more regular updates to take advantage of the benefits of performance, stability, and compatibility improvements.

1 Like

@novabyte Eep! Thanks for the info.

I don’t know how I could have been using an 18 month old library when it was newer than what we got from the asset store at project start in March 2019!

I’m certain there’s some definite improvements, so now it’s just about weighing the costs/benefits between fixing the issue and upgrading the system — I try not to fix what’s not broken :slight_smile:

Thanks again!

Best,

Sean

@Chance6Sean That’s definitely odd. Are you sure its the 2.1.0 release you use? You can see the release notes for the client sdk on GitHub: https://github.com/heroiclabs/nakama-unity/releases/v2.1.0

Yup! Hadn’t had a single issue with it until the iOS build either. Either way, now I’ve got a way to fix the problem so I’m happy; just surprised we’d ended up with such an old library at the start of a relatively young project.

Thanks again!

Best,

Sean