itisnajim / SocketIOUnity

A Wrapper for socket.io-client-csharp to work with Unity.
MIT License
393 stars 67 forks source link

v3/4 Auth isn't supported? #10

Closed DaveKap closed 2 years ago

DaveKap commented 2 years ago

Running a very simple server that uses auth according to the documentation here: https://socket.io/docs/v4/server-socket-instance/#sockethandshake I have discovered that this plugin has no way to send the auth object needed. Doing it through the query field, as documented for this plugin, leaves a handshake on the server log that looks like this:

connection from a socket
{
  headers: { connection: 'keep-alive', host: 'localhost:8000' },
  time: 'Mon May 16 2022 14:01:12 GMT-0700 (Pacific Daylight Time)',
  address: '::1',
  xdomain: false,
  secure: false,
  issued: 1652734872041,
  url: '/third_party//?EIO=4&transport=polling&auth=123',
  query: [Object: null prototype] {
    EIO: '4',
    transport: 'polling',
    auth: '123'
  },
  auth: {}
}

Note how the auth field is empty. Is there some way of filling in that field that is undocumented? I notice that there is no auth option at the Query/EIO/Path/ExtraHeader level, SocketIOOptions, which is where it needs to be.

itisnajim commented 2 years ago

You can use SocketIOOptions to pass the query object like in the example https://github.com/itisnajim/SocketIOUnity#initiation and check in the server like this: https://github.com/itisnajim/SocketIOUnity#server-example this repo its just a wrapper for socket.io-client-csharp You should open the issue there if you can't find an answer!

DaveKap commented 2 years ago

I believe there has been a miscommunication, so allow me to explain in more depth. I'm trying to connect to a server that I do not have control over but have been given the ability to pull logs from. As I explained, the server uses auth as indicated by the documentation I linked. The auth object is at the same hierarchy level as query, it is not nested within query, as seen in the log I provided (the auth: {} at the bottom.) Submitting auth through the query object does not get it sent to the auth object in standardized Socket.IO architecture, as documented, and you can see the result of that in the query object, also as seen in the log I provided.

I checked the repo you suggested I open an issue on. That which you are wrapping does, in fact, have an auth object as an option available for socket connections. I need your wrapper to take advantage of that specific hierarchy of auth. As is, the query object level of auth is not actually doing this, as evidenced by the log I have provided. The problem with your wrapper is solved when I can get that auth: {} at the end of that log filled in. In its current state, this is not possible.

EDIT: Figured out what's wrong. See: https://github.com/itisnajim/SocketIOUnity/issues/13