by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 04 11:57
    clue demilestoned #89
  • Aug 04 11:57
    clue milestoned #89
  • Aug 04 10:53
    clue commented #86
  • Aug 04 10:52
    clue labeled #86
  • Aug 04 10:52
    clue labeled #86
  • Aug 04 10:36
    clue commented #384
  • Aug 04 10:35
    clue labeled #384
  • Aug 03 18:15
    tlaverdure closed #384
  • Aug 03 18:15
    tlaverdure commented #384
  • Aug 03 13:13
    tlaverdure opened #384
  • Aug 01 14:48
    clue commented #383
  • Aug 01 14:48
    clue closed #383
  • Aug 01 14:48
    clue commented #383
  • Aug 01 14:32
    clue labeled #383
  • Aug 01 12:52
    clue closed #213
  • Aug 01 12:52
    clue commented #213
  • Aug 01 12:50
    clue labeled #213
  • Aug 01 12:01

    jsor on master

    Change default socket backlog s… Merge pull request #242 from cl… (compare)

  • Aug 01 12:01
    jsor closed #242
  • Aug 01 11:45
    kelunik commented #242
Christian Lück
@clue
It's technically possible to run multiple different protocols over a shared port (port multiplexing) or possibly using HTTP upgrades to use multiple protocols over a shared HTTP socket, but this requires some in-depth understanding of your transport protocol
My recommendation would be to start with the first option, get this up and running and if you're really interested in the second option, shoot me an email :D
Dean Clatworthy
@deanclatworthy_twitter
It's not a deal-breaker for me to run it on the same port, what is a deal breaker is that clients are agnostic to which service they are connected to
I'm still a bit stuck with that. How to share connections between the two services for example? Do I just wrap the two servers and keep track of clients on both?
Christian Lück
@clue
@deanclatworthy_twitter I'm not sure I follow what exactly you're trying to build, but why wouldn't the clients know which service/port they are connecting to? You don't use your web browser to access IMAP/SMTP and likewise can't use your mail client to access a website.
It's technically possible to run multiple protocols over the same port, but things get way more involved in this case and it's rarely worth the effort
Take a look at https://github.com/leproxy/leproxy/blob/master/src/ProtocolDetector.php for a possible implementation of a protocol multiplexer using HTTP or SOCKS (a binary protocol) over the same port
Dean Clatworthy
@deanclatworthy_twitter
@clue sorry if i'm not being clear. I just want to be able to do the same things as a client of my service regardless of if im connected via tcp or websockets. If i send a message via tcp, all clients get it regardless of if they are on websocket or tcp. and vice versa. websocket client sends message, all tcp get it too. It is completely acceptable to me to run the service on two ports.
Christian Lück
@clue
In this instance, we concluded that users often confuse different proxy protocols and it would be a nice feature to support either proxy protocol over the exact same port
If I understand your problem correctly, you're building a "chat-like" application which accepts incoming connections through websockets and plain TCP/IP sockets?
Dean Clatworthy
@deanclatworthy_twitter
yes, currently only tcp/ip
Christian Lück
@clue
In this case, I would definitely go for 2 independent ports (one for each protocol) and then "route" the data from both ends
Dean Clatworthy
@deanclatworthy_twitter
It's this "route" that i am struggling to grasp. I can probably just store the clients for websockets and tcp/ip in an array so i can relay messages regardless of which server it comes in to. but is there something built in to help with this?
Christian Lück
@clue
Create one ThroughStream which you use as your broadcast mechanism, then for each incoming connection send all data to this one stream and likewise forward all data from it to each connection
If you're building a distributed application, I would go for something like Redis' Pub/Sub channels, e.g. https://github.com/clue/reactphp-redis#pubsub
For a simple demo, it's probably sufficient to use a ThroughStream, everything else would be overkill 👍
Ibe Arua
@myquery
hello there, i just got back to using php after many years off it, now i got to use ratchet for my current app using symfony as my php framework. i don't know, maybe i am approaching wrong, but my implemetation requires Ratchet websocket application messaging protocol under ratchet; Ratchet\ConnectionInterface and Ratchet\Wamp\Topic because the Gos web-socket bundles requires to implement the TopicInterface. Please help and guidance. thanks
Dean Clatworthy
@deanclatworthy_twitter
Thanks for the nudge in the right direction @clue - will try and take a look at ThroughStream
Christian Lück
@clue
@deanclatworthy_twitter Always happy to help 👍 Keep us posted if you make some progress :-)

hello there, i just got back to using php after many years off it, now i got to use ratchet for my current app using symfony as my php framework. i don't know, maybe i am approaching wrong, but my implemetation requires Ratchet websocket application messaging protocol under ratchet; Ratchet\ConnectionInterface and Ratchet\Wamp\Topic because the Gos web-socket bundles requires to implement the TopicInterface. Please help and guidance. thanks

@myquery Welcome back to the wonderful world of PHP :-)

I would highly recommend keeping your WebSocket application and your web application separated, i.e. Symfony or any other framework should not affect what your WebSocket part looks like
You can always pass messages between both "parts" of your application using socket connections
You can think of both parts as separate repos if that helps, but you can also keep everything in a monorepo if that helps with your development process
Ibe Arua
@myquery
@clue thank you chris for the quick response, so you are saying i should discard the GOs-websocket Bundle?
@clue it implements the topic interface
Christian Lück
@clue
I'm not a Symfony-person, so better also get some other opinions on this one ✌️
Use whatever provides most value for your use case, but there's really no "right" or "wrong" here 🤷
Ibe Arua
@myquery
@clue thanks chris, will gladly wait for use feedback
Alex Pavlov
@alexpts
How to wait for all streams to be written before stopping the event loop?
Now I'm waiting for 2 ticks of the event loop.
Christian Lück
@clue
@alexpts What are you trying to achieve exactly? The event loop will stop automatically if there's nothing else left to do, so you don't usually need this level of control
3 replies
Marc Rovira
@lelu85
Hi everyone, I have a question around react. If I want to create a infinite loop inside a child process, like a consumer type of command with a react, does react manage the memory leaks with his EventLoop class? 'cos in php usually if you dont manage unsets and things like that in an infinite loop, memory crashes
Cees-Jan Kiewiet
@WyriHaximus
Hey @lelu85 the event loop doesn't take care of that. And it can't because if doesn't controll your code. As long as you write your code in such a way that any copies or references aren't there anymore the garbage collector will clean up for you
Ole Rößner
@Basster
hi everybody. Is there any experience with ReactPHP and graphics libraries like [g|i]magick or gd? esp. when font files involved?
Christian Lück
@clue
@Basster Yep, here 👋 I would highly recommended running CPU-intensive functions (and filesystem access) in a child process
I'm currently working on some better APIs to make this easier to use in PHP with https://github.com/clue/reactphp-pq
But in the meantime you can always wrap this in a separate PHP file and run this with https://github.com/reactphp/child-process
Cees-Jan Kiewiet
@WyriHaximus
@Basster yup done that, what are you planning to do with it?
Ole Rößner
@Basster
thx @clue and @WyriHaximus I'm already on the right path, as it seems. Refactored some custom font rendering out of an monolythic Symfony app into a driftphp wrapper. Its already a lot faster but not really non-blocking, since I've just migrated the code as is. As some custom opentype rendering via harfbuzz (hb-view binary as child-process) is already involved, I thought about migrating the gmagick font rendering stuff the same way. Thanks for pinpointing me.
Cees-Jan Kiewiet
@WyriHaximus
@Basster Ok cool! Was going to suggest https://github.com/reactphp-parallel/worker-pool otherwise (just finished the documentation). Used it in the past to do GD work with it
Olatunbosun Egberinde
@bosunski
@WyriHaximus @cboden @clue I see some templating engines use include/require, Is there any non blocking alternative to require or include since both are blocking?
Cees-Jan Kiewiet
@WyriHaximus
This message was deleted
@bosunski As long as they use it to load a generated class once, and then use that loaded class to render a template it's fine. But if it happens every time you have an issue
IIRC Twig does that
Christian Lück
@clue
@bosunski What @WyriHaximus said :-)
You might be able to work around this by using non-blocking filesystem I/O and eval() and friends :)
Do you like nasty options? 😏
$ php -d allow_url_include=1  -r 'require "data://text/plain,<?php echo PHP_VERSION;";'
Cees-Jan Kiewiet
@WyriHaximus
That works?!
Olatunbosun Egberinde
@bosunski

Oh Thanks @WyriHaximus and @clue.

That second option though... i'm blown 🤯🤯🤯.