简体   繁体   中英

Server(web) and Clien(mobile) application communication via rest api within a LAN

I have a senario where the server app should be exchanging data with a client mobile app through REST API within a Local Area Network.

Here is my approach, I am generating a WIFI from the server-app(LapTop) and try to force that to have a static IP andress using this on windows:

exec('netsh interface ipv4 set address "Wi-Fi" static 192.168.1.50 255.255.255.0 192.168.0.1';)

and on the client side, I am trying to fire a request like this:

http://192.168.1.50/api/customers

Now my worry is that creating the WIFI seems to be tricky because at time it will fail and appart from that the request through the above url is not working keep saying network request failed.

Please I need your suggestions, remarques, expertizes about the concept. Is that a good approach about this kind of problem. My constraint is that a client should be connected to the LAN before he can make any api request (So, for sure I can not use the internent).

Thanks in advance

As per as my suggestion set one Personal Computer(PC) as server and install apache server in it. create My SQL database and make PHP web service to interchange data from client to server and vice versa. Also keep one router in your area and connect PC and all mobiles to that router as Wifi connected. Now call http://192.168.1.50(server PC IP)/api/customers from mobiles you can interchange data with it. Use volley or other Rest Client library to call PHP api. if you are not aware of PHP then you can make web service using IIS and .Net technology as well java and Tomcat/Glass fish server

For the static IP address, try binding it on the router level. When your mobile app is in the same wifi as with your server, it should be able to access that IP address.

Accessing it from the internet is possible, but would be different. Try to research about nginx and port forwarding. Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM