SocketException: The requested address is not valid in its context.
Hi, so I'm trying to create a deepstream client with Unity, and I installed the await/async asset so it will be 100% similar to the examples given here. but I still can't make it work because of the SocketException.. I tried the example Program.cs as a console app and the connection works fine, so it's not a problem of connectivity or server-related issues.
I realise it's not common to use Unity as a client but it should be fairly possible considering Unity is now .NET 4.x compatible..
So this is my Unity code:
public class DeepstreamManager : MonoBehaviour
{
private DeepStreamClient client;
async void Start()
{
client = new DeepStreamClient("localhost", 6020);
if (await client.LoginAsync())
{
var eventSubscription = await client.Events.SubscribeAsync("test", x => { print(x); });
client.Events.Publish("test", "Hello");
client.Events.Publish("test", 42);
}
}
}
And this is the exception:
SocketException: The requested address is not valid in its context.
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () (at <9577ac7a62ef43179789031239ba8798>:0)
DeepStreamNet.DeepStreamClient+<LoginAsync>d__17.MoveNext () (at <a91fb4570bc84808b3ad9f1017f460a2>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () (at <9577ac7a62ef43179789031239ba8798>:0)
DeepstreamManager+<Start>d__1.MoveNext () (at Assets/Scripts/DeepstreamManager.cs:16)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) (at <9577ac7a62ef43179789031239ba8798>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <82ec470c913149358ad0c83ad628910c>:0)
UnityEngine.UnitySynchronizationContext:ExecuteTasks()
Has anyone managed to make Unity work with Deepstream?
Hi @orenkoren, unfortunately I never worked with Unity, so I cannot say if your error is Unity related or not. Maybe the Unity Environment is running in a kind of emulator and cannot call your deepstream server because of some virtual network boundaries? The exception also is kind of generic. Would it be possible to get a better Exception/Stacktrace? Maybe you can put a try/catch around your code inside the Start method and then output the Exception via Exception.ToString() and post it here.