TCP to HTTP communication - java

I have an IOT device which is sending data continuously to a configured server using TCP protocol.
Can i receive the data using HTTP protocol and any java http services application like spring-boot application?
Device details : https://teltonika.lt/product/fmb920/

As the device was returning the data in TCP protocol so I could not get any solution to get data in http protocol.
I achieved that by establishing the TCP connection using sockets.

Related

Out of order data in TCP

I've an application that's using Apache mina library for communicating based on TCP. The apache mina library provides a callback with IOBuffer that contains data coming over the network, however often times the data is received out of order or redundantly. I skimmed through the TCP protocol and it says that the protocol always ensures delivery of the data in correct order. The company that provided the APIs for their server claim that they are using TCP/IP for sending the response back however before sending the response back their server doesn't care about confirming if the client (in this case my application/apache mina library) is connected to the server. So the server just fires off the message and moves on.
If I'm not mistaken, that's the UDP protocol's behavior. My question is, if the server is using TCP for sending the response back:
Why do I get out of order data (it's rare but happens one in a while)?
How can a machine that's using TCP protocol just fire and forget about the data without making sure the receiver device is connected to it before sending the data?
Is this really TCP or UDP or some variation of TCP protocol?
Apache Mina does asynchronous messaging over the top of various transports including TCP.
Since Mina is asynchronous, out-of-order delivery should be expected.
Why do I get out of order data (it's rare but happens one in a while)?
One possible explanation is that multiple TCP streams are being used. Data delivered using one TCP stream will be delivered in order, but if multiple streams are used, data in one stream could "overtake" data on another stream, in the TCP stacks on the sending or receiving end, on the network, or in the client side library.
How can a machine that's using TCP protocol just fire and forget about the data without making sure the receiver device is connected to it before sending the data?
Because ... reliable delivery is not a basic attribute of Mina.
If you are using Mina to talk to a service with a particular application protocol, then that protocol will determine will determine whether "sending the data before checking the receiver is connected" is allowed / will work or not. For example, it won't for an HTTP response, because an HTTP response is sent on a connection that was previously established to send the request.
Actually, it seems that there are a variety of ways to use Mina. Some involve an application protocol; e.g. see HttpClientCodec and HttpServerCodec. Others don't.
Is this really TCP or UDP or some variation of TCP protocol?
If they say that TCP is being used as transport, then it is. However, Mina is neither TCP or UDP. It is Mina. It hides the details of the transport.
Bottom line, if you want the reliability / in-order delivery properties of TCP/IP, you should probably use them directly. Mina is providing higher performance than conventional TCP/IP over a synchronous socket by relaxing the normal properties of a (single) stream-based transport.

how to secure Socket communication so that only authorised client application can connect or listen to the port of server application

I have server application which runs on local host and the client also runs on local host.
As of now I am using java.net.serversocket and any application which has the ip and port detail of server can listen to the port.
My requirement is to secure the ports or secure the communication between the server and client application such that only my application client (authorised) one can listen to the ports or connect to server application. The data sent to and from client and server also has to be secured.
Apologies if naming conventions are not correct. I have been searching for solution and couldn't get anything for this, all I got is how to connect and make application communicate using socket programming , but no where I got the answer as how to secure the communication.
What you need here is some sort of authentication method to authorise only your client to communicate with the server. If you are using an existing communication protocol then it might have a specification for authentication already. If you are using your own protocol then you'll have come up with your own design for authentication.
It could be as simple as the server issuing some sort of request for authentication to the client. The client would then have to provide a satisfactory response (eg a user/password) otherwise the server would close the connection.
I would recommend taking a look at how some other protocols (eg HTTP) handle authentication to get some insight and also understand potential pitfalls.

Communicate between web server and raspberry pi

Assume that I have web server (ad-box.deslab.vn) and raspberry pi is a client connected to my web server. (Server and Client is not in local network)
Beside using socket, How can I send a string from web server to raspberry pi?
What languages can I use to code for web server and client?
You can use MQTT (MQ Telemetry Transport or Message Queue Telemetry Transport) which is an ISO standard publish-subscribe-based lightweight messaging protocol for use on top of the TCP/IP protocol. It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth is limited.
Below you can find the list of some MQTT clients in various languages.
http://www.hivemq.com/blog/seven-best-mqtt-client-tools
https://www.ibm.com/support/knowledgecenter/SS9D84_1.0.0/com.ibm.mm.tc.doc/tc10100_.htm

How Spymemcache client use UDP?

As it is seen that the Spymemcache client use TCP connection to connect with Memcached server as default. I want to use UDP instead of TCP. I think Facebook use UDP to get() requests from Memcached.
Any one know how to use UDP with SpyMemcache ?

How to connect to SMSC server over SMPP protocol?

Respected All! I'm working on a project where we are developing an SMS-based disaster management system.
we have to send a request to an SMSC server over SMPP protocol to broadcast an SMS to all of its Subscribers. The cellular company has provided us with the IP/port, username and pasword to connect to their SMSC server.
I'm a bit confused on what steps should be followed to connect to their SMSC server?
kindly someone answer my following questions:
1) How to connect to the SMSC server over SMPP protocol?
2) Do we have to create our own SMPP server to send request to the SMSC server?
3) If the answer to Question# 2 is yes, then how to send request to SMSC server from SMPP server?
Any help will be appreciated! Thanks in advance!
"If your provider uses the HTTP Protocol to have sms sent over to them then you would need to use HTTP POST/GET method. On the other hand if your provider uses the SMPP (Short Message Peer to Peer) Protocol you would have to use the same to connect to them."-Source
So, it looks like the provider is using SMPP protocol. That's means you have to set up a SMSC connection. You would need to use a Java API for this, download these libraries in your project. There should be documentation on how to set things up in the Java documentation with the download. gl
Another option is the Open Source Mobicents SMSC server, which supports SMPP, SIP and SS7/SIGTRAN interfaces, as well as HTTP REST APIs via Restcomm.
In fact you may want to consider promptly building the SMS handling logic with the Restcomm Visual Designer and use the External Service feature to integrate with the rest of your business logic.
https://code.google.com/p/smscgateway/
http://www.restcomm.com/

Categories