achilleasa / dart_amqp

Dart AMQP client implementing protocol version 0.9.1
MIT License
79 stars 40 forks source link

web pltform #38

Open mohammadshrahi opened 4 years ago

mohammadshrahi commented 4 years ago

hello,i was trying this package on mobile platforms (android /ios) and it's work fine. but what about web. I think add web support it's will be a big contribution

achilleasa commented 4 years ago

Apologies for the late reply. Can you elaborate more on your particular use-case? For web applications you would typically connect to amqp from your backend and use some sort of push mechanism (e.g. websockets) to talk to the front-end.

hettan commented 4 years ago

First, thanks for an awesome lib!

I'm also looking for web support. My use case is that I have an app that I like for Android, iOS and web. While your suggestion for websocket would work it does make the architecture a bit more complex since now I will have platform dependent code and need to add that functionality to my backend. If there was web support for AMQP I could have the same architecture for all of the three client platforms. Which is one of the core things you want when making apps in flutter IMO.

Note that I'm not really a web developer, only worked a lot with Android before, so I might have missed some important aspect here.

But it would be awesome to get web support for this library!

bahricanyesil commented 3 years ago

Is there any change about this issue? I also encountered with the same problem. I want to know whether there is an easy way to connect to rabbitmq in flutter web without any backend. Do you still think not to add web support @achilleasa ? If you found any solution, can you share @mohammadshrahi , @hettan ?

achilleasa commented 3 years ago

AFAICT the main issue (as you can see here) that prevents it from running on the web is the dart:io import. However, the universal_io package might be a drop-in replacement that could make this work in a browser.

As I am not familiar with using Dart on the web, can you provide me with a mimimal test app that I can use to verify that it actually works?

ali77gh commented 3 years ago

AFAICT the main issue (as you can see here) that prevents it from running on the web is the dart:io import. However, the universal_io package might be a drop-in replacement that could make this work in a browser.

As I am not familiar with using Dart on the web, can you provide me with a mimimal test app that I can use to verify that it actually works?

Hi I tried that (replacing import (dart.io -> universal_io) according here)

The API is exactly the same API as dart:io. You can simply replace dart:io imports with package:universal_io/io.dart. Normal dart:io will continue to be used when your application runs in non-Javascript platforms

It works on linux but not on Web (chrome) and according this issue its because socket is not allowed in browsers.

So the only way to make it work on web is implementing this with WebSocket.

stephane-segning commented 1 year ago

Hello any updates on this?

boaz-amit commented 1 year ago

Hey. There's no direct implementation of the AMQP protocol over HTTP. This is for example why there's no proper AMQP client in JS for browsers.

In browsers, usually protocols like MQTT and STOMP are used in such cases. RabbitMQ has built-in plugins that enable these protocols, usually over websockets.

Since this package is an AMQP implementation in Dart, it would be out of its scope to implement any other protocol.

The mqtt_client and stomp_dart_client should be suitable for the web.

stephane-segning commented 1 year ago

Simply put: I should go look for mqtt_client or stomp_dart_client. Understood. Thank you for your feedback!

boaz-amit commented 1 year ago

That is my personal opinion and recommendation 🙂I cannot speak for the package’s developer of course.


From: Stephane SEGNING LAMBOU @.> Sent: Sunday, July 23, 2023 3:45:36 PM To: achilleasa/dart_amqp @.> Cc: Boaz Amit Danhi @.>; Comment @.> Subject: Re: [achilleasa/dart_amqp] web pltform (#38)

Simply put: I should go look for mqtt_client or stomp_dart_client. Understood. Thank you for your feedback!

— Reply to this email directly, view it on GitHubhttps://github.com/achilleasa/dart_amqp/issues/38#issuecomment-1646844506, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA35ME5GLKFTHDKML4MJHKLXRUTIBANCNFSM4KLLGSMA. You are receiving this because you commented.Message ID: @.***>

JerichoCross commented 10 months ago

RabbitMQ and Azure Service Bus both support AMQP over websockets. Implementing the choice between socket and websocket would open this up to web users.

achilleasa commented 10 months ago

As mentioned above, supporting websockets requires to implement the STOMP protocol which is fundamentally different than the AMQP binary protocol that this client implements.

However, it might be possible to tweak the underlying socket implementation to use a Websocket to TCP bridge like https://github.com/cloudamqp/websocket-tcp-relay. Note that in this case, you would still need to host the relay somewhere and provide a TLS certificate to secure the connection.

If folks find this use-case interesting, I will allocate some time to work on it.

JerichoCross commented 10 months ago

RabbitMQ and Azure Service Bus both support AMQP over websockets. Implementing the choice between socket and websocket would open this up to web users.

Apologies - it is AMQP 1.0 that has built-in support for websockets and not v0.91. My mistake.