Jmu5667 Well-Known Member Licensed User Longtime User Dec 13, 2016 #1 Hello All I have been educating myself on Web-sockets etc and they are very powerful and easy to implement. We have an up and coming server app to develop and I want to use B4J. The app must be multi-threaded as it is going to receive tracking data from many different GPS devices which will have different GPS protocols. Some of this devices operate in a fire and forget method and some of them require some form of acknowledgement. I am sure it is possible to develop this server app using B4J but I have not been able to find any server examples that when a connection is created a new thread is created to handle the data exchange. There will be an MS SQL server back-end database so a DB thread pool will be required. I would also like to know how threads are disposed of in this case. I have seen other tracking apps that support many different devices and they assign a port number for each type of app. Is it possible to do something similar with B4J. Many thanks for reading this and I look forward to all suggestions and advice. Regards John.
Hello All I have been educating myself on Web-sockets etc and they are very powerful and easy to implement. We have an up and coming server app to develop and I want to use B4J. The app must be multi-threaded as it is going to receive tracking data from many different GPS devices which will have different GPS protocols. Some of this devices operate in a fire and forget method and some of them require some form of acknowledgement. I am sure it is possible to develop this server app using B4J but I have not been able to find any server examples that when a connection is created a new thread is created to handle the data exchange. There will be an MS SQL server back-end database so a DB thread pool will be required. I would also like to know how threads are disposed of in this case. I have seen other tracking apps that support many different devices and they assign a port number for each type of app. Is it possible to do something similar with B4J. Many thanks for reading this and I look forward to all suggestions and advice. Regards John.
Erel B4X founder Staff member Licensed User Longtime User Dec 13, 2016 #2 Jmu5667 said: I am sure it is possible to develop this server app using B4J but I have not been able to find any server examples that when a connection is created a new thread is created to handle the data exchange. Click to expand... This is always the case with B4J WebSocket handlers. Each connection is managed by a different thread. The threads are returned to the threads pool when the connection is closed. Jmu5667 said: I have seen other tracking apps that support many different devices and they assign a port number for each type of app Click to expand... You don't need to use different ports. Use different paths instead. Upvote 0
Jmu5667 said: I am sure it is possible to develop this server app using B4J but I have not been able to find any server examples that when a connection is created a new thread is created to handle the data exchange. Click to expand... This is always the case with B4J WebSocket handlers. Each connection is managed by a different thread. The threads are returned to the threads pool when the connection is closed. Jmu5667 said: I have seen other tracking apps that support many different devices and they assign a port number for each type of app Click to expand... You don't need to use different ports. Use different paths instead.
Jmu5667 Well-Known Member Licensed User Longtime User Dec 13, 2016 #3 Hi Erel Thanks for the response. I thought with web sockets that the client also must use a web socket, am I wrong in thinking this ? Most devices just use a raw socket,open the port, transmit and close. Regards John. Upvote 0
Hi Erel Thanks for the response. I thought with web sockets that the client also must use a web socket, am I wrong in thinking this ? Most devices just use a raw socket,open the port, transmit and close. Regards John.
Erel B4X founder Staff member Licensed User Longtime User Dec 13, 2016 #4 Jmu5667 said: I thought with web sockets that the client also must use a web socket, am I wrong in thinking this ? Click to expand... That's correct. See this: https://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content Upvote 0
Jmu5667 said: I thought with web sockets that the client also must use a web socket, am I wrong in thinking this ? Click to expand... That's correct. See this: https://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content
Jmu5667 Well-Known Member Licensed User Longtime User Dec 13, 2016 #5 How do I handle devices that use raw sockets and not web sockets ? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Dec 13, 2016 #6 Which type of devices? Upvote 0
Jmu5667 Well-Known Member Licensed User Longtime User Dec 13, 2016 #7 The likes of this https://www.amazon.co.uk/Tracker-Ve...?ie=UTF8&qid=1481634529&sr=8-1&keywords=tk103 Also here is a link https://www.traccar.org/ to a service that we have used before, but they are unable to modify there system to cope with some specific device from http://2015.twigcom.com/pages/en/twig-products/twig-protector.php and this device requires an acknowledgement. We do a lot of business with this company. Regards John. Upvote 0
The likes of this https://www.amazon.co.uk/Tracker-Ve...?ie=UTF8&qid=1481634529&sr=8-1&keywords=tk103 Also here is a link https://www.traccar.org/ to a service that we have used before, but they are unable to modify there system to cope with some specific device from http://2015.twigcom.com/pages/en/twig-products/twig-protector.php and this device requires an acknowledgement. We do a lot of business with this company. Regards John.
Erel B4X founder Staff member Licensed User Longtime User Dec 13, 2016 #8 Can it send http requests? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Dec 13, 2016 #10 You need to use ServerSocket to handle those devices. It can run inside the web server, listening on a different port. I recommend you to learn this example: https://www.b4x.com/android/forum/threads/mjpeg-cctv-server.73792/#content It shows how you can, quite easily, handle multiple connections with raw sockets. Upvote 0
You need to use ServerSocket to handle those devices. It can run inside the web server, listening on a different port. I recommend you to learn this example: https://www.b4x.com/android/forum/threads/mjpeg-cctv-server.73792/#content It shows how you can, quite easily, handle multiple connections with raw sockets.