Android Question Secure and limit connections to MJPEG / CCTV Server

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Hi everybody ,

To save Erel and DonManfred :D some time , I decided to start a new thread

I am using Erel's example from this thread https://www.b4x.com/android/forum/threads/mjpeg-cctv-server.73792/

I needed two things:

1- Limit connections so only one device (browser ) can view cam stream .

2- Make my connection secure for example by a password that should be typed correctly to view the stream .

Thanks in advance
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1- Limit connections so only one device (browser ) can view cam stream .
This one is more tricky than it might seem. Browsers can make multiple connections. You can close old connections when there is a new connection (Server_NewConnection) however you will probably encounter cases where the wrong connection is closed.

2. This line in Client.Astream_NewData reads the http request and makes sure that the client tries to connect to the root.
B4X:
'filter out favicon calls
If line.Trim <> "GET / HTTP/1.1" Then

You can change it to:
B4X:
if line.Trim <> "GET /SecretPath HTTP/1.1" Then

Now you will need to enter the following URL in order to connect: http://<ip>/SecretPath
 
Upvote 0
Top