Skip to content

Support WebSockets version in ConnectionFactory #1

Open
@ScottKane

Description

For some reason a normal System.Net.Sockets.Socket isn't supported in WASM (I thought it was but it turns out the browser doesn't support sockets), is there any chance you can support using System.Net.WebSockets on the ConnectionFactory so that this can properly be used in WASM Blazor applications?

Here is an example of the issue (this app is using preview versions of GrpcLite from your myget feed): https://github.com/ScottKane/GrpcLiteWasm

You should be able to run this app and see normal behaviour, however if you uncomment the code in Client\Program.cs, when you run, the app will throw an exception in the browser:

System.AggregateException: One or more errors occurred. (System.Net.Sockets is not supported on this platform.)
 ---> System.PlatformNotSupportedException: System.Net.Sockets is not supported on this platform.
   at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
   at ProtoBuf.Grpc.Lite.ConnectionFactory.<>c__DisplayClass2_0.<<ConnectSocket>b__0>d.MoveNext() in /_/src/protobuf-net.GrpcLite/ConnectionFactory.cs:line 75
--- End of stack trace from previous location ---
   at ProtoBuf.Grpc.Lite.ConnectionFactory.<>c__DisplayClass13_0.<<AsStream>b__0>d.MoveNext() in /_/src/protobuf-net.GrpcLite/ConnectionFactory.cs:line 346
--- End of stack trace from previous location ---
   at ProtoBuf.Grpc.Lite.ConnectionFactory.<>c__DisplayClass12_0`1.<<AsFrames>b__0>d[[System.Net.Sockets.NetworkStream, System.Net.Sockets, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() in /_/src/protobuf-net.GrpcLite/ConnectionFactory.cs:line 327
--- End of stack trace from previous location ---
   at ProtoBuf.Grpc.Lite.ConnectionFactory.CreateChannelAsync(Func`2 factory, CancellationToken cancellationToken) in /_/src/protobuf-net.GrpcLite/ConnectionFactory.cs:line 427
   at Program.<Main>$(String[] args) in D:\Repos\GrpcLiteWasm\Client\Program.cs:line 18
   --- End of inner exception stack trace ---

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions