GithubHelp home page GithubHelp logo

Comments (5)

6562680 avatar 6562680 commented on July 25, 2024

Also maybe it is PHP thing, not NATS, but i tried to wait until server send me -ERR 'Stale connection' and then write to socket something. Then i start to read messages. Unexpectedly i've received all pending responses from the socket and, in general, server response me. Why? If i received 'Stale Connection' according by docs - server should CLOSE the socket and maybe clear unread buffer. Even after that i receive all pending messages, error inside them, and can continue writing to socket. In advance socket was closed once i tried to READ from socket that send me "Stale Connection". So socket closes once i read, but not if i try to WRITE (i even checked socket remotely closed state and get FALSE to be sure). I repeat, maybe it is a PHP thing, but maybe a NATS one (maybe it is required to support JetStreams). Also i tried to write some message to 'Stale Connection' socket and didn't get the answer, seems correct. But if i send CONNECT first, socket becomes alive and getting commands again. What does it mean? I think we can create tonns of sockets, all of them could become 'Stale Connection', but (internally i dont know) still has in NATS registry with possible overflow or trigger "limitConnections" in future. Guess NATS just replace dummy sockets once alive socket gets in, but then we again could to receive unexpected situation where sockets was replaced and one of old replaced socket unexpectedly becomes alive and start to writing.

(above quote is not actual, sorry me, server didn't sent all pending messages, only new ones after receiving connect, possible PHP restores connection when i WRITE something to socket, guess is not nats problem)

from nats.docs.

6562680 avatar 6562680 commented on July 25, 2024

Guess i dont count parallel features. To escape responses from different request it should be different opened connections... So if we open new connection for each sid we work only with our messages, and messageId is not needed. That way we can escape blocking until one handler processing reply for his request and other handlers waiting for.

Guess each SUB message should open new connection, allowing engineer to create connection pool, that we check in a cycle with timeout. Same thing should be for PUB message with reply-to provided... There could be PUB with reply-to and then SUB with reply-to subject. User possible should add handler only for SUB openning new connection for each SUB then he receive answers only for his commands instead of all messages in one flow...

Actually noob mode and messageId would be great feature until user wants to ignore Pool feature, but currently it is very recommended.

Also adding handlers for just 'MSG' forces to run N handlers for each incoming message. Instead it should be some filter for message fields to run only 2-3 callbacks required for certain task. Well, if handlers started only by sid then we always know how many handlers we start.

One thing i hate in pool - highload. So many connections from single machine even with "parallel" could unexpectedly exhaust max_connection_limit or something. And what would we say if we start to talk about cluster... Connection count exponentially increased.

It will be harder than i expect.

from nats.docs.

6562680 avatar 6562680 commented on July 25, 2024

Tried async and sync, and just unable to solve case.

If confirmation/response doesn't have pointer to what exactly it covers - unable to work with these confirmations.

Ping should be confirmed with pong. We use socket, so when reading we could receive few pongs (in case of long time wait) - we again dont know what pong to what ping to be sure that it works.

from nats.docs.

Jarema avatar Jarema commented on July 25, 2024

fyi there is already an actively maintained NATS PHP client: https://github.com/basis-company/nats.php with JetStream, KV etc.

from nats.docs.

6562680 avatar 6562680 commented on July 25, 2024

Thats why i rewrite it. There's not junior code, but not senior code, OOP cries, looping too, unable to async processing, am trying to explore.

Fully synchronyous blocking client with wall of code, but actually - few features is working. I tried to cooperate with - they mark task as "somewhen" and leave.

from nats.docs.

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.