doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
745 stars 128 forks source link

cannot connect to glitch or heroku #289

Open meytotr opened 2 years ago

meytotr commented 2 years ago

its work for localhost or ipadress:port.. but not work for glitch or heroku.. not work for remote server

magdev2022 commented 1 year ago

This error is solved now?

Shourya-BrainAlive commented 1 year ago

If someone is able to resolve this or found a different solution/library then, please reply. It would be really helpful.

doghappy commented 1 year ago

Is there a service available for testing?

doghappy commented 1 year ago

I have just tried to create a socket.io server on glitch, then use this lib to connect. It seems that glitch require a User-Agent header

          using var io = CreateSocketIO();
          io.Options.ExtraHeaders = new Dictionary<string, string>()
          {
              ["User-Agent"] =
                  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.50",
          };

          await io.ConnectAsync();
magdev2022 commented 1 year ago

I have tried with above code, but I got same error result.

doghappy commented 1 year ago

I've fixed it, need to do this in 3.0.8

          using var io = CreateSocketIO();
          io.Options.AutoUpgrade = false;
          io.Options.ExtraHeaders = new Dictionary<string, string>()
          {
              ["User-Agent"] =
                  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.50",
          };

          await io.ConnectAsync();

reasons:

  1. glitch required a User-Agent header.
  2. could not connect socket.io server by ws if socket.io hosted on glitch
magdev2022 commented 1 year ago

I deployed socket server on aws. other clients(python, nodejs, java) are running well. but only C# has an error.

jrichardsz commented 3 months ago

Same error.

It works very well with unity IDE but with a real android device, it never connects to the socket io server.