rdkcentral / mock-firebolt

An advanced, controllable mock Firebolt OS implementation, which can also act as a reverse proxy to a real Firebolt OS running on a real device
Apache License 2.0
4 stars 21 forks source link

SYSTEST-9250 1-1 WS Mapping for Proxy Mode #115

Closed ksentak closed 1 year ago

ksentak commented 1 year ago

Create 1-1 WS mapping instead of a singleton WS connection when MF is in proxy mode.

ksentak commented 1 year ago

Hey @michaelcfine, I want to give some more background regarding this PR so you can better understand the code changes:

Currently, on each new incoming connection to Mock Firebolt in Proxy Mode a WS object is created and assigned to the user. That same WS object is used to create a "messageHandler" for that user. Inside of that message handler, if Proxy Mode is enabled, a message is forwarded to the proxied endpoint. That forwarding is done through a separate WS object.

That proxying is currently done through a singleton WS object. Ripple opens several connections to MF. The result is mapping several incoming WS objects to one outgoing WS object. An unintended consequence of this is that when events/replies come in from the proxied endpoint, they are not going to the correct incoming WS object and events are not working properly on a Ripple connection.

A solution to the issue mentioned in the above paragraph is to turn the outgoing WS singleton into a 1:1 mapping with each incoming WS object.

When an incoming WS requests a message sent to the proxied endpoint, we now:

Check a WS:WS map to see if the incoming WS object has an outgoing WS object If the map contains an entry for the incoming WS object, use it If the map does not contain an entry, create an outgoing WS object and assign it to the map