Giter VIP home page Giter VIP logo

Comments (9)

mrjoes avatar mrjoes commented on August 27, 2024

Явная бага socket.io - он перестал отправлять arguments для multiplexed соединений.

Грубо говоря, для примера выше, происходит следующее:

  1. socket.io открывает сервер по URL и передает параметры сразу через URL, так что их принимает дефолтный хендлер
  2. По открытому соединению посылается пакет на соединение к '/chat' без параметров

Должно быть наоборот:

  1. Без параметров подключение к серверу
  2. Отправка пакета вида: '1:::/chat?test=chat' для виртуального соединения.

В целом - я открою у них тикет.

from tornadio2.

klen avatar klen commented on August 27, 2024

Спасибо.

from tornadio2.

mrjoes avatar mrjoes commented on August 27, 2024

Как вариант обхода проблемы, на текущий момент, могу посоветовать следующее.

Например есть ситуация, когда необходимо передавать некий token, по которому можно будет определить пользователя:

  1. Делать авторизацию в роутере
  2. Из виртуальных соединений делать что-то типа: self.session.conn.current_user_id
  3. При открытии соединения, в клиенте, убедиться что token передается в первом вызове (socket.io сохраняет параметры на уровне сессии, а не отдельного соединения - кто первый вызвал io.connect, того и тапки).

Тикет открыл: socketio/socket.io-client#331

from tornadio2.

klen avatar klen commented on August 27, 2024

Я проверил старые версии soket.io до 0.7.5 включительно и ни одна из них не имеет отличного поведения. Может быть так и задумано и стоит сохранять параметры у родительского подключения передавая их при создании дочерних?

from tornadio2.

mrjoes avatar mrjoes commented on August 27, 2024

Протокол утверждает иное, https://github.com/LearnBoost/socket.io-spec:

Example, if the client is trying to connect to the endpoint /test, a message like this will be delivered:

'1::' [path] [query]
Example:

1::/test?my=param
Так что это явная бага, как минимум по следующим причинам:

  1. Имеет значение в каком порядке соединяемся. Т.е. если первый io.connect без query string, а второй будет чего-то передавать, то в результате ничего не передастся даже в родительское соединение.
  2. Теряем query string для всех последующих соединений
  3. Абсолютно нелогичное поведение которое не соответствует их же протоколу.

from tornadio2.

klen avatar klen commented on August 27, 2024

Да действительно, пока не починят отфоркаю tornadio2. Мне нужен этот функционал, а soket-io-client отпатчить сложнее :) Надеюсь быстро починят.

from tornadio2.

mrjoes avatar mrjoes commented on August 27, 2024

А зачем форкать? Можно обойти так:

class ChatConnection(SocketConnection):
def on_open(self, info):
self.send('Chat open connection')
self.send(self.session.conn.info.arguments)

class RouterConnection(SocketConnection):
def on_open(self, info):
self.send('Router open connection')
self.info = info

   __endpoints__ = {'/chat': ChatConnection,
                   '/ping': PingConnection}

Сергей.

from tornadio2.

mrjoes avatar mrjoes commented on August 27, 2024

Ух оно режет русский, если ответ письмом.

from tornadio2.

klen avatar klen commented on August 27, 2024

Да логично, не заметил, что создается линк на session. А я уже написал сохранение request.query в session.init и добавление его к url в connect_endpoint.

from tornadio2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.