As the title says... Chat on...

User avatar
By snice
#30946 Hi,

Here is my code:

Code: Select alllocal postdata="testdata"
local postLength=string.len(postdata)
local sck=net.createConnection(net.TCP, 0)
sck:on("receive", function(sck, payload)
                  print("received")
                  print(payload)
                  sck:close()
               end)
   
sck:on("sent",function(sck)
            print("sent")                   
           end)
             
sck:on("disconnection", function(sck)
                     print("disconnection...")                               
                     sck = nill
                  end)


sck:on("connection",function(sck)
                  print("connected")               
                  sck:send("POST /MyService/api/Measure HTTP/1.1\r\nHost: xxxxxxxxxx.com\r\n"
                  .."Connection: keep-alive\r\n"
                  .."Cache-Control: no-cache\r\nContent-Type: application/json"
                  .."\r\nContent-Length: "..postLength.."\r\nAccept: */*\r\n\r\n"
                  ..postdata)
               end)       
print("connection...")
sck:connect(80,'xxxxxxxxxx.com') 


Sometimes I have this output:
connection...
connected
sent
received
content of the payload
disconnection...

but after a while (sometimes even from the beginning) I have:
connection...
disconnection...

anyone ever had this type of issue?

Thank you
Last edited by snice on Fri Oct 09, 2015 8:56 am, edited 1 time in total.
User avatar
By snice
#30949 I created a function (sendData) that I call each minutes and here is the result:
tmr.alarm(0,60000, 1, function() sendData() end )

First request output:
connection...
disconnection...

second request output:
connection...
connected
sent
received
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 09 Oct 2015 13:40:31 GMT
Content-Length: 0

disconnection...

third request output:
connection...
disconnection...

fourth request output:
connection...
disconnection...

We can see that without touching anything sometimes it works...
User avatar
By TerryE
#31235 If the connection is sometimes rejected at the server end, then you'd see what you are getting.