-->
Page 1 of 3

How to limit Client to one and reject new connection ?

PostPosted: Sun May 17, 2020 8:17 am
by Belthazor
So Basically I made an IOT.. a doll claw machine that can be controlled through website using ESP8266 + port forwarding . But I got problem that I can't limit my clients. If there are more than 1 clients who give the command to the ESP8266, it will listen to both commands..( it will just listen to any Https Get Command sent )

I am thinking another page before user can get into to "control access of my claw machines" but i need to make that page to display "machine is BUSY " if ESp8266 is currently got connected by other user..

Hope somebody can help me.. :D :D :D :D

Re: How to limit Client to one and reject new connection ?

PostPosted: Sun May 17, 2020 4:29 pm
by btidey
You could do something like have a variable to hold the ip address of the client that connects to the server and a variable that holds the time when this first connected. The client ip is an easily accessible property of the server during a request.

You then check subsequent requests and if they match you allow control and update the time variable.

If they don't then you respond with a busy message unless the time exceeds some timeout from the last access. This allows another client to take over after an idle period..

This scheme would not stop two clients run on the same platform from conflicting.

Re: How to limit Client to one and reject new connection ?

PostPosted: Mon May 18, 2020 7:38 pm
by Belthazor
Any example with The time stamping and session destroy coded into Esp8266' webserver ??

Re: How to limit Client to one and reject new connection ?

PostPosted: Sun May 24, 2020 8:43 am
by Belthazor
Can We Do something like this ??

There is a page before connecting to the machine (esp8266) ..something like landing page contains a clickable Icon of machine1, machine 2, machine3 etc.
This landing page will constantly send a Get Request to check the esp8266 status.

If currently there is a client connected to the esp8266 the return will be "Busy " ,and its will be displayed on the landing page, also "Machine icon" will disabled.( Cant be click) .. however if the machine is available..the icon on the landing page will show available and enabled to be clicked.

Anybody have idea how to implement it ? With example and some code if possible.