http://10.253.251.69/?command=dataquery&uri=dl:Public.RainHr(1)&mode=most-recent
I am trying to use the API commands inside an Http get statment to query from another logger. Both loggers on private apn.
I can run the query from browser with no issue and ping the remote loggers but I can not get the loggers to see each other.
even a pingIP command to the other logger fails so I think I have not setup the paths correctly
code below with important bits if you can comment if I am on the right path
Public HTTPResponse
Public RemoteRainHr As String
Const URLString = "http://10.253.251.69/?command=dataquery&uri=dl:Public.RainHr(1)&mode=most-recent"
Public TCPSocket As Long
Public Ping_result
Public SiteIP As String
'Define Data Tables.
'Main Program
BeginProg
Scan (30,Sec,0,0)
SW12 (1 )
SiteIP = PPPOpen
TCPOpen ("10.253.251.69",3000,0,750,TCPSocket,2)
Ping_result = PingIP ("10.253.251.69",2000)
HTTPResponse = HTTPGet (URLString , RemoteRainHr ,"")
TCPClose (TCPSocket)
the Public table of the logger show
Table Name: PublicCurrent Record: 76
Record Date: 2016-05-31 17:02:14.29
PTemp25.76285batt_volt13.9328HTTPResponse0RemoteRainHr"Error: failed to connec"TCPSocket0Ping_result0SiteIP"10.253.251.104"
the second logger I added this code to open the tcp tunnel but not sure if this is correct
SlowSequence
Scan (30,Sec,0,0)
SW12 (1 )
TCPOpen ("10.253.251.104",3000,0,750,TCPSocket,2)
any help suggestions or comments much appreciated
Paul
If one logger is not able to ping the other logger, and you haven't disable ping on the logger, then you probably have a firewall blocking access within your network.
Depending on your cell modem service provider, they might not allow M2M or Mobile to Mobile communications. This could be another reason one logger is not able to reach the other logger.
Thanks for the comments, I will look into the ping and M2m comms capability.
Does my code set look correct then ?
I was not sure if I had applied the TCPOpen statement correctly for both loggers or if it was needed
cheers
Paul
Further information..
I have checked both loggers
The primary in my example is a CR300 which I dont have the option to enable Ping(ICMP) which might be part of the ping issue? In early version of code I was checking the network function by Ping to our sever and this was ok; thanks on the suggestion about M2M between modems so will look into that further.
the target is a CR800 with ping enabled
Both units I can hit from PC with just their IP address so that part is ok and both modems I can ping remotely
The modems are set for the Logger to initiate the TCP connection, I am using ATD*99***1#
cheers
Further further information
contacted our Service Provider (vodafone nz) and M2M is a no go...
currently looking for work arounds.. any ideas appreciated
Because there is no M2M, you are not going to be able to use the WebAPI. There is the possibility that you could use GetVariables() in the one logger to get data from the other logger. It will require a PakBus router be placed on the Internet somewhere with a public TCP/IP address that both dataloggers can reach (using the PakBusTCPClient setting in each logger). A NL201, NL240, or another datalogger with Ethernet or WiFi can be used as a PakBus router. Both dataloggers and the router will require unique PakBus addresses in order for GetVariables() to work as well.