This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Reading event notifications from Grandstream GDS3710
#1
I'm trying to setup event notification for the grandstream GDS3710.
I cannot use an lp script since the gds3710 only accepts an ip and port
   

I've searched the forum for a simple resident script which is able to capture the data the gds3710 sends when an event occurs but without any luck.
I've found a script which at least generates some output but not the whole body.
Code:
* string: POST / HTTP/1.1User-Agent: Wget/1.16.1 (linux-gnu)Accept: */*Accept-Encoding: identityHost: 192.x.x.x:7777Connection: Keep-AliveContent-Type: application/x-www-form-urlencodedContent-Length: 29


Can someone point me to the right direction or alter the script below.

Code:
local socket = require("socket") local server = assert(socket.bind("*", 7777)) local header while 1 do   local client = server:accept()   local line = client:receive()   header = line   while (#line > 0) do     line = client:receive()     header = header .. line   end   log(header)  end

Thanks in advance!
Reply
#2
Try this:
Code:
local socket = require("socket") local server = assert(socket.bind("*", 7777)) local crlf = '\r\n' while true do   local client = server:accept()   client:settimeout(5)   local pat, len   while true do     local res, err = client:receive(pat)     if err then       break     end     if type(pat) == 'number' then       client:send(         'HTTP/1.1 200 OK' .. crlf ..         'Connection: close' .. crlf .. crlf       )       log(res) -- contains request body       break     elseif #res == 0 then       pat = len     elseif not len then       len = res:match('Content%-Length: (%d+)')       len = tonumber(len)     end   end   client:close() end
Reply
#3
(13.04.2023, 08:55)admin Wrote: Try this:
Code:
local socket = require("socket") local server = assert(socket.bind("*", 7777)) local crlf = '\r\n' while true do   local client = server:accept()   client:settimeout(5)   local pat, len   while true do     local res, err = client:receive(pat)     if err then       break     end     if type(pat) == 'number' then       client:send(         'HTTP/1.1 200 OK' .. crlf ..         'Connection: close' .. crlf .. crlf       )       log(res) -- contains request body       break     elseif #res == 0 then       pat = len     elseif not len then       len = res:match('Content%-Length: (%d+)')       len = tonumber(len)     end   end   client:close() end

Works as a charm! 
Thank you very much admin! Cool
Reply


Forum Jump: