Ruzihm / STOMPWebSocketsPlugin

1 stars 1 forks source link

Subscribe problem #3

Closed vigeronz closed 7 months ago

vigeronz commented 7 months ago

Hello. Thank you for the plugin but I have a problem. The fact is that it successfully connects by URL, but then does not subscribe to topics, to any topics

I also used your preview project, everything is the same. it connects successfully but does not subscribe

Log: LogStomp: Warning: Got a receipt with an unknown or unhandled recept id sub-1-ID\ctest-stand23-41445-1707384289796-4\c372

-------Update-------- It’s really strange why I’m not receiving messages messages are coming, but I get this message in the logs:

LogStomp: Warning: Received a message from /topic/390d2826-5b4a-422e-b783-34a6924f437c.MediaProfile000.ForbiddenAreaDetector.a693afd5-c172-30b8-9702-e82278e03822 with an unknown or unhandled subscription id sub-0-ID\ctest-stand23-36633-1708085333552-4\c96

-------Update-------- I looked at the code and for some reason I'm not getting through the if

        if (!Subscriptions.Contains(Id))
        {
        UE_LOG(LogStomp, Warning, TEXT("Received a message from %s with an unknown or unhandled subscription id %s"), *Message.GetDestination(), *Id);
        }
        else
        {
        Subscriptions[Id].ExecuteIfBound(Message);
        }

although at the beginning, when subscribe, it generates the ID itself and adds it to the list of subscribers

this question message was duplicated from EpicGames Marketplace if you answered there, then I will delete this

Thank you

Ruzihm commented 7 months ago

I will see if I can reproduce this bug but I have not encountered this yet.

My first guess is that the client is being reset after the subscriptions occur. Can you confirm for me that you are not calling BuildClient after calling Subscribe?

vigeronz commented 7 months ago

no, I'm not calling BuildClient after Subscribe

I recorded a video https://youtu.be/J0Rj9x-4SAI

why in the first message ID starts with "sub-1" and then when you receive a message ID starts with "sub-0" test

sub-1-ID\ctest-stand23-36633-1708085333552-4\c117
sub-0-ID\ctest-stand23-36633-1708085333552-4\c117
Ruzihm commented 7 months ago

Thanks for the video and details.

Looking here it seems that sub-0 indicates the 0th frame from the client was a subscribe frame, and sub-1 indicates the next frame (index 1) was also a subscribe frame. The client seems to me as if it is sending multiple subscribe messages but then forgetting about them before the server can confirm receipt of the "index 1" subscription. I'm a little unsure why that would be happening.

Can you have your BP print the return value of the subscribe node? It may reveal how many subscriptions this instance is attempting to send

I'm still having trouble reproducing this issue - are you able to start from a fresh project and reproduce this bug?

vigeronz commented 7 months ago

this is a new project

https://github.com/Ruzihm/STOMPWebSocketsPlugin/assets/60131882/c16f5b93-c03d-4f5f-8ced-b028b1ce3b16

I could send you the project itself but I didn't do anything special, it's a completely empty project with your plugin

Moreover, I tried to connect to this address and subscribe through your example project same error

Ruzihm commented 7 months ago

Maybe I'm having issues reproducing the problem because of a version difference. What unreal ver are you using?

Something else I'm curious about is what frames are being sent - can you use something like wireshark to see what frames are going between the unreal project and the activemq server?

vigeronz commented 7 months ago

UE5.3 I also tried it on 4.27 and 5.1

ok I'll try to get more information

Ruzihm commented 7 months ago

I've switched from rabbitmq to activemq and I'm seeing similar errors now. Looking into this.

Edit: it looks like the active mq server and the client disagree about what characters need to be escaped...

Edit2: apparently the colon character is not supposed to be a permitted character in header values in stomp 1.1 and 1.2. looking into this.

Ruzihm commented 7 months ago

It seems like active mq is using colons in its values for the session header. Apparently this is something that is allowed in a CONNECTED frame. But Unreal's STOMP implementation seems to not escape the colons correctly.

vigeronz commented 7 months ago

what can we do? Is it possible to rewrite Unreal's StompClient class? or other workarounds

Ruzihm commented 7 months ago

Regrettably, there's not a way to specify your own subscription id using the Unreal stomp client (as it is currently written) and it builds it directly from the session id that the server sends. I'm working on a pull request for fixing the bug in the unreal engine. I'll link it in this thread when I submit it.

In the meantime...

There might be a way to configure activemq to use a different way of generating session ids which don't include colons. I wasn't able to find anything but I'm unfamiliar with the codebase and configuration options.

I hate to say it but switching clients or servers might be the most direct solution at this time. :(

I know rabbitmq generates session ids that don't include colons if you want to try a different server.

If you are inclined to delve into the Unreal STOMP client code, you could create a child class of StompClient which uses an alternative to MakeID and ensure that colons get substituted with something else. But then you would need to instantiate it in an appropriate way. This plugin uses stompModule->CreateClient but that only would create StompClient so a suitable alternative would be needed.

vigeronz commented 7 months ago

Ok thanks a lot for the answer Then we'll wait for a fix from Epics

and my last question, this is of course not necessary if it takes up too much of your time could you give me some more hints on what is the best way for me to successfully integrate the rewritten class into your plugin?

Ruzihm commented 7 months ago

If you can get an instance of a suitable child class of StompClient and assign it to the StompClient field of STOMPWebSocketClient in BuildClient that should work in theory

vigeronz commented 7 months ago

I downloaded UnrealEngine from Git and rewrote the line MakeID it worked

Ruzihm commented 7 months ago

Yay!!

I was having issues getting the engine to build from source and now I wont have access to my dev box for another week. If you can do me a favor, could you try building my master branch here https://github.com/Ruzihm/UnrealEngine/tree/master and see if that also fixes it?

vigeronz commented 7 months ago

yes of course, I'll try it in a few days

Ruzihm commented 7 months ago

I am wondering if I may have started my branch from the wrong branch. I'll get back to this soon and see what I can do. Thanks for your help anyway!

Edit- yeah i was on the 4.27 branch - Testing on the latest 5.x branch now. Will update if I end up pushing anything to the unreal repo. Closing for now but feel free to comment if anything major happens.

vigeronz commented 7 months ago

Thank you too and thank you for the plugin By the way, I'm sorry, I couldn't find time for your request. if the request is still relevant, I can do it

Ruzihm commented 7 months ago

I was able to build the engine from source so I can test my changes after all. Thank you for your kind offer of help 🙂