Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"NullReferenceException" before the first connection attempt. #75

Closed
corthax opened this issue Oct 24, 2022 · 3 comments
Closed

"NullReferenceException" before the first connection attempt. #75

corthax opened this issue Oct 24, 2022 · 3 comments
Labels
User Error This issue was caused by user error

Comments

@corthax
Copy link

corthax commented Oct 24, 2022

With or without server, before the first connection attempt console is spammed with errors. After - it's ok.

After clients are connected everything seems to work fine...

Custom project (based on your youtube tutorial).

All breaking code changes are applied.
Installed with Package Manager.

On client, without server:
2022-10-24 18_31_50-Game

On client, with server:
2022-10-24 18_33_05-Game

On server, throw error after client connects, for each client:
2022-10-24 18_46_45-Window

@tom-weiland
Copy link
Collaborator

The only thing that could cause a NullReferenceException on line 297 of the Client class is connection being null, which it will be if you haven't initiated a connection yet. However, Riptide itself does not try to send any messages before initiating a connection, which means that you must be trying to send something before connecting...

Do you send messages in Update or from anywhere else which might execute before you call your client's Connect method?

@corthax
Copy link
Author

corthax commented Oct 24, 2022

Oh well. Indeed I send messages on Update before client is connected. Previous RiptideNetworking version was ok with that :D
Connection null check with some error message would be nice though, for debugging.

@tom-weiland tom-weiland added the User Error This issue was caused by user error label Oct 25, 2022
@tom-weiland
Copy link
Collaborator

Previous RiptideNetworking version was ok with that

I'm pretty sure it just silently discarded the message though. It wouldn't have tried to actually send it without being connected.

Connection null check with some error message would be nice though

I mean you are getting an error message (the NullReferenceException), and the stack trace should show you exactly what your own code is calling to cause it—it's just that it doesn't explicitly tell you "you can't send messages until you're connected."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User Error This issue was caused by user error
Projects
None yet
Development

No branches or pull requests

2 participants