handzlikchris / Unity.QuestRemoteHandTracking

Oculus Quest hand tracking directly in Unity Editor for fast iteration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The request addess is not valid in this context

piede828 opened this issue · comments

Added the IP address that shows up in IPconfig in both the sender and the receiver but I get the above message in the console when running in the Editor

Hi,

This could be due to some network setup on your machine, there's a thread that has some information
https://stackoverflow.com/questions/30889972/the-requested-address-is-not-valid-in-its-context-when-i-try-to-listen-a-port

Looks like you can not bind on that specified IP Address. You can also try and edit TcpReciever.cs where listener is created.

public void StartListeningOnNewThread()
        {
            tcpListenerThread = new Thread(() =>
            {
                tcpListener = new TcpListener(IPAddress.Parse(_listenOnIp), _listenOnPort);
                tcpListener.Start();
                Debug.Log("Server is listening");
                tcpListener.BeginAcceptTcpClient(StartReadingTcpConnectionData, new object());
            });
            tcpListenerThread.IsBackground = true;
            tcpListenerThread.Start();
        }

change that
tcpListener = new TcpListener(IPAddress.Parse(_listenOnIp), _listenOnPort);
to
tcpListener = new TcpListener(IPAddress.Any, _listenOnPort);

Hi

Thanks for this. I've updated the script to read all IPs but when I launch the app on the Quest it won't get past the Unity launch screen and freeze. Any idea why?

Hi

Not sure, other issue seems to be very similar #7, can you send Quest logs from logcat, please.
There should be something there to point us in right direction.

Also I couldn't recreate that on my end but perhaps I have some minor difference in project that's causing this. If you're using that on clean solution can you share the whole code, maybe that'll allow me to reproduce.

Here is the error I see:

2020/01/28 13:49:07.197 25516 25530 Error Unity: Keep alive error, System.InvalidOperationException: The operation is not allowed on non-connected sockets. 2020/01/28 13:49:07.197 25516 25530 Error Unity: at System.Net.Sockets.TcpClient.GetStream () [0x00036] in <b623971dded64b99a996db9f0cc46906>:0 2020/01/28 13:49:07.197 25516 25530 Error Unity: at Assets.RemoteHandsTracking.Utilities.TCPSender.SendInternal (System.Byte[] message) [0x0000a] in <72350c7700974d0b99e567b2e32ea583>:0 2020/01/28 13:49:07.197 25516 25530 Error Unity: at Assets.RemoteHandsTracking.Utilities.TCPSender.Send (System.Byte[] message) [0x00013] in <72350c7700974d0b99e567b2e32ea583>:0 2020/01/28 13:49:07.197 25516 25530 Error Unity: at Assets.RemoteHandsTracking.Utilities.TCPSender.SendKeepAlivePacket () [0x00006] in <72350c7700974d0b99e567b2e32ea583>:0 2020/01/28 13:49:07.197 25516 25530 Error Unity: at Assets.RemoteHandsTracking.HandsDataSender+<KeepTcpAlive>d__10.MoveNext () [0x0001f] in <72350c7700974d0b99e567b2e32ea583>:0 2020/01/28 13:49:07.197 25516 25530 Error Unity: 2020/01/28 13:49:07.197 25516 25530 Error Unity: (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35) 2020/01/28 13:49:07.197 25516 25530 Error Unity:

In the Editor, I'm getting this:

Unable to get hand data, System.Threading.ThreadAbortException at (wrapper managed-to-native) System.Net.Sockets.Socket.ReceiveFrom_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool) at System.Net.Sockets.Socket.ReceiveFrom_internal (System.Net.Sockets.SafeSocketHandle safeHandle, System.Byte* buffer, System.Int32 count, System.Net.Sockets.SocketFlags flags, System.Net.SocketAddress& sockaddr, System.Int32& error, System.Boolean blocking) [0x0000c] in <735c83e43c004ee998f77c68cf8035da>:0 at System.Net.Sockets.Socket.ReceiveFrom (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint& remoteEP, System.Net.Sockets.SocketError& errorCode) [0x00024] in <735c83e43c004ee998f77c68cf8035da>:0 at System.Net.Sockets.Socket.ReceiveFrom (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint& remoteEP) [0x00026] in <735c83e43c004ee998f77c68cf8035da>:0 at System.Net.Sockets.Socket.ReceiveFrom (System.Byte[] buffer, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint& remoteEP) [0x00000] in <735c83e43c004ee998f77c68cf8035da>:0 at System.Net.Sockets.UdpClient.Receive (System.Net.IPEndPoint& remoteEP) [0x00036] in <735c83e43c004ee998f77c68cf8035da>:0 at Assets.RemoteHandsTracking.HandsDataReceiver.ListenForUdpData () [0x00005] in C:\Users\pietr\OneDrive\Documents\THREESIXTY\Hand Guns\Assets\RemoteHandsTracking\HandsDataReceiver.cs:68 UnityEngine.Debug:LogError(Object) Assets.RemoteHandsTracking.HandsDataReceiver:ListenForUdpData() (at Assets/RemoteHandsTracking/HandsDataReceiver.cs:73) System.Threading.ThreadHelper:ThreadStart()``

This looks like network connection can not be made. Can you check

  • if you're firewall is allowing connections on that port?
  • is Quest on same network as PC, eg. same wifi?
  • is your PC ip correct in sender? Depending on your network setup your PC IP can change from time to time, ipconfig should give you the answer. If you want to keep it static it's usually easiest to set up static DHCP reservation for your PC

I've checked all those and they're good.
I've put a few debug.log in HandsDataSender but the Quest is not logging anything via Logcat...so it looks like it's not even try to send at the moment

can you try with non-train scene package from here - in other issue #7, that seemed to fix initial oculus quest freeze.

BTW, that log cat should show something, it may not show Debug.Log that you've put it as the application likely freezes before that. Is it showing anything related to app launch? I'd expect to see some error shorty after that.

I've chased some other options as I thought there might be some issues with new version or something.

All I found is I can not use loopback address 127.0.0.1 in receiver, you have to use your PC proper address.

Tested on clean setup with package without train-scene (simple framework) dependence on Unity 2019.3.0f6

Hi handzlikchris,
firstly, thank you for your work!
Unfortunately im having a similar problem with above "Unable to get hand data, System.Threading.ThreadAbortException
".
-Same network
-Opened port 27000
-Disabled firewall
-Same ip adress on both sender and receiver

Unable to get hand data, System.Threading.ThreadAbortException
at (wrapper managed-to-native) System.Net.Sockets.Socket.ReceiveFrom_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool)
at System.Net.Sockets.Socket.ReceiveFrom_internal (System.Net.Sockets.SafeSocketHandle safeHandle, System.Byte* buffer, System.Int32 count, System.Net.Sockets.SocketFlags flags, System.Net.SocketAddress& sockaddr, System.Int32& error, System.Boolean blocking) [0x0000c] in :0
at System.Net.Sockets.Socket.ReceiveFrom (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint& remoteEP, System.Net.Sockets.SocketError& errorCode) [0x00024] in :0
at System.Net.Sockets.Socket.ReceiveFrom (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint& remoteEP) [0x00026] in :0
at System.Net.Sockets.Socket.ReceiveFrom (System.Byte[] buffer, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint& remoteEP) [0x00000] in :0
at System.Net.Sockets.UdpClient.Receive (System.Net.IPEndPoint& remoteEP) [0x00036] in :0
at Assets.RemoteHandsTracking.HandsDataReceiver.ListenForUdpData () [0x00005] in C:\Users\Stefano\Documents\Repos\KineticXr-Wedge\ProjectWedge\Assets\RemoteHandsTracking\HandsDataReceiver.cs:68

Hi @StefanoDef ,

There are 2 issues that I was able to identify

  • first, error in editor, as you see
    • for me that was down to invalid IP, I was using loopback 127.0.0.1, what is exact IP you're using?
  • second was quest app freezing on startup
    • this was again IP not reachable via quest, it's freezing as Quest is making blocking call to IP address, if all goes well you don't see that but if IP is not reachable it's freezing.

Generally I don't think it'll be code issue but rather network. Are you familiar with wireshark? https://www.wireshark.org/ - it may be easiest to run it on PC and see if any packets are coming in from Quest.

Hi @handzlikchris
Thks for your reply,
I tried with my pc ip on sender/receiver and headset ip on sender/receiver
also tried these ips on both, in short, any combination, but could not get it working.Tbh havnt noticed any freezing, just errors. A couple of times, no errors were displayed but could not see my hands nonetheless. I will investigate with wireshark and try with the loopback ip.