11-11-2011 11:27 AM
Hi,
I am trying to make a simple http post with labview. Screenshot is as attachment, the string coming from left is 100 bytes long and the boolean is true.
Until tcp-read everything is ok: no errors, and I get some bytes written. output called "Bytes written" in tcp-write-block is 100, the length of my string.
Then tcp-read times-out. Why? Also if I check my external webserver, there is no incoming data from labview machine IP.
If I change the IP-address to labview machine IP, I get an error from labview services (this is correct responce as my string is malformed).
If I use windows telnet to connect from labview machine to external webserver, the server logs show incoming transmission and return error string (as I just type just some letters to telnet console).
I googled this forum, and there was a "solution" that I must change my ip addresses to 192.168.x.x for this to work. All our machines are now in 10.0.0.x network. Changing IP addresses is out of the question, even for trial purposes.
Another problem might be that my webserver port is a high port 39334.
I made a quick hack by calling external python script that works (urllib2.Request(a,b) and urllib2.open(c) is excactly what I want to do):
import json
import urllib2
import random
testData = []
for i in range(10):
testData.append(random.random())
params = json.dumps({"analogStrain" : testData,
"stress" : testData,
"digitalStrain" : testData})
s = params + '\n'
req = urllib2.Request(url = "http://10.0.0.1:39334/cmd/viewer/viewerUpdateTtmData.cgi",
data = s)
f = urllib2.urlopen(req)
Conclusions:
- the the 10.x.x.x network is ok
- 127.0.0.1 labview is ok
- python script called from labview works
- 10.0.0.x network called from labview is broken
How do I post http using labview?
11-14-2011 09:11 AM
Is there another way use http post than I am using? For example, is there a ready web package with http-post?
br,
Juha
04-11-2022
07:15 AM
- last edited on
11-06-2024
05:03 PM
by
Content Cleaner
Use the LabVIEW HTTP Client functions:
Like most LabVIEW comms, open a session and specify your port number, then call the POST function.