B4J Question HTTP reverse proxy

wl

Well-Known Member
Licensed User
Longtime User
Hi,

I'm trying to implement a HTTP reverse proxy in B4J.

The implementation is simple:
- the application is listing on port 80 (serversocket)
- when a connection is made a (client) socket is created: it connects to the "real" website
- both sockets exchange data (data received on one socket is sent to the other and visa versa).

In fact, currently it is just an attempt to do port forwarding in B4J.

I make sure to take into account multi threading (I keep a list of socket pairs).

For a simple website it seems to work, but as soon as concurrent requests are being made it fails. I guess it has to do with multi threading functionality in B4J ?

Thanks
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I guess it has to do with multi threading functionality in B4J ?
No. It is most probably a problem in your code.

I would have used jServer for such solution. However you can implement it with AsyncStreams. Best way is to implement it in a class and create a new instance for each connection.
 
Upvote 0

wl

Well-Known Member
Licensed User
Longtime User
thank you Erel, but as I do not have control on the websites it proxies it seem a jServer application is too limited, I guess ?

As it needs to proxy any website it needs access on the lowest level possible, I don't see how an webapplication in jServer can match that ?

Thanks
 
Upvote 0
Top