<div dir="ltr"><div>Hi,</div><div><br></div><div>Not sure if this helps, but as far I knew you need to use Lua version 5.2, not 5.1</div><div><br></div><div><a href="https://freeswitch.org/confluence/display/FREESWITCH/mod_lua">https://freeswitch.org/confluence/display/FREESWITCH/mod_lua</a><br></div><div><br></div><div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-confluence-information-macro gmail-confluence-information-macro-warning"><div class="gmail-confluence-information-macro-body"><p>Since FreeSWITCH 1.4, you need to use Lua5.2 (<a class="external-link" href="http://www.lua.org/manual/5.2/" rel="nofollow">http://www.lua.org/manual/5.2/</a>).</p><p>For those willing to keep using Lua5.1 for backwards compatibility reasons, there is a mod_lua available in <strong>legacy</strong> directory `freeswitch/src/mod/legacy/languages/mod_lua/`</p></div></div></blockquote><div> </div></div><div><div><div><div dir="ltr" class="gmail_signature"><div dir="ltr">Jurijs<br></div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 22, 2018 at 6:23 PM Joel Serrano <<a href="mailto:joel@textplus.com">joel@textplus.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Also, from your logs it seems you have compiled LUA manually? Maybe the problem can be there.<br></div><div><br></div><div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">This is where the lua http lib is in debian8:</div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">root@debian:~# dpkg -S /usr/share/lua/5.1/socket/http.lua</div><div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">lua-socket:amd64: /usr/share/lua/5.1/socket/http.lua</div><div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">root@debian:~#</div></div><br></div><div>If you are using the distribution-package-lua make sure you have the <b>lua-socket</b> package installed (or whatever the package name is in your distro, this example applies to debian8),<br></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Cheers, </span></div><div>Joel.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 21, 2018 at 4:23 PM, Joel Serrano <span dir="ltr"><<a href="mailto:joel@textplus.com" target="_blank">joel@textplus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>This is a snippet of a LUA script I'm using:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="monospace, monospace">...</font></div><div><div><font face="monospace, monospace">require "ltn12"</font></div></div><div><div><font face="monospace, monospace">conn = require "socket.http"</font></div></div><div><div><font face="monospace, monospace">conn.TIMEOUT = 2</font></div></div><div><div><font face="monospace, monospace"><br></font></div></div><div><div><font face="monospace, monospace">function sendRequest()</font></div></div><div><div><font face="monospace, monospace"> local path = "<a href="http://example.com/" target="_blank">http://example.com/</a>"</font></div></div><div><div><font face="monospace, monospace"> local payload = "SOME_JSON"</font></div></div><div><div><font face="monospace, monospace"> local response_body = { }</font></div></div><div><div><font face="monospace, monospace"><br></font></div></div><div><div><font face="monospace, monospace"> local res, code, response_headers, status = conn.request</font></div></div><div><div><font face="monospace, monospace"> {</font></div></div><div><div><font face="monospace, monospace"> url = path,</font></div></div><div><div><font face="monospace, monospace"> method = "POST",</font></div></div><div><div><font face="monospace, monospace"> headers =</font></div></div><div><div><font face="monospace, monospace"> {</font></div></div><div><div><font face="monospace, monospace"> ["Authorization"] = "Basic SOMETHING",</font></div></div><div><div><font face="monospace, monospace"> ["Content-Type"] = "application/json",</font></div></div><div><div><font face="monospace, monospace"> ["Content-Length"] = payload:len()</font></div></div><div><div><font face="monospace, monospace"> },</font></div></div><div><div><font face="monospace, monospace"> source = ltn12.source.string(payload),</font></div></div><div><div><font face="monospace, monospace"> sink = ltn12.sink.table(response_body)</font></div></div><div><div><font face="monospace, monospace"> }</font></div></div><div><div><font face="monospace, monospace"> session:setVariable("my_http_res, res)</font></div></div><div><div><font face="monospace, monospace"> session:setVariable("<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">my_</span>http_code", code)</font></div></div><div><div><span style="font-family:monospace,monospace"> session:setVariable("</span><span style="font-family:monospace,monospace">my_</span><span style="font-family:monospace,monospace">http_status", status)</span><br></div></div><div><div><font face="monospace, monospace">end</font></div></div><div><div><font face="monospace, monospace"><br></font></div></div><div><div><font face="monospace, monospace">sendRequest()</font></div></div><div><font face="monospace, monospace">...</font></div></blockquote><div><br></div><div><br></div><div>In my case, I have to do a <b>POST</b> of an "<b>application/json</b>" with <b>Basic auth</b>.</div><div><br></div><div>I found this pretty helpful:</div><div><br></div><div><a href="http://w3.impa.br/~diego/software/luasocket/http.html" target="_blank">http://w3.impa.br/~diego/software/luasocket/http.html</a><br></div><div><br></div><div><br></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">lol I also remember going through a headache to get this "simple" thing working..</span><br></div><div><br></div><div><br></div><div>Hope it helps!</div><span class="m_1813619249991324294HOEnZb"><font color="#888888"><div><br></div><div>Joel.</div><div><br></div><div><br></div></font></span></div><div class="m_1813619249991324294HOEnZb"><div class="m_1813619249991324294h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 19, 2018 at 10:57 PM, Jose David Jurado Alonso <span dir="ltr"><<a href="mailto:josedavid@zennio.com" target="_blank">josedavid@zennio.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><pre class="m_1813619249991324294m_-3054141171032008409m_7703539112658186186gmail-tw-data-text m_1813619249991324294m_-3054141171032008409m_7703539112658186186gmail-tw-ta m_1813619249991324294m_-3054141171032008409m_7703539112658186186gmail-tw-text-small" id="m_1813619249991324294m_-3054141171032008409m_7703539112658186186gmail-tw-target-text" style="height:144px" dir="ltr"><span lang="en">Thank you very much David, if you find the script it would be a great help.
I have been on vacation and I have not been able to try much more in this time.</span></pre><div><div class="m_1813619249991324294m_-3054141171032008409h5"><div class="gmail_extra"><div><div class="m_1813619249991324294m_-3054141171032008409m_7703539112658186186gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><p style="font-size:12.8px"><span style="font-size:small">2018-08-03 20:07 GMT+02:00 David Villasmil </span><span dir="ltr" style="font-size:small"><<a href="mailto:david.villasmil.work@gmail.com" target="_blank">david.villasmil.work@gmail.com</a>></span><span style="font-size:small">:</span><br></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Oh this took me some time to figure out, i'll dig up ny script and share it with you.</p>
<br><div class="gmail_quote"><div><div class="m_1813619249991324294m_-3054141171032008409m_7703539112658186186h5"><div dir="ltr">On Fri, Aug 3, 2018, 13:16 Jose David Jurado Alonso <<a href="mailto:josedavid@zennio.com" target="_blank">josedavid@zennio.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_1813619249991324294m_-3054141171032008409m_7703539112658186186h5"><div dir="ltr">Hi,<div><br>I have tried to make a HTTP POST request from LUA script but it does not work correctly in any way.<div><div><br></div><div>This is an example of the errors that I have obtained:
<div><br></div></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 2018-08-03 12:23:07.981581 [ERR] mod_lua.cpp:203 error loading module socket.core from file /usr/local/lib/lua/5.1/socket/core.so:</font></div></div></div></div></div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 <span style="white-space:pre-wrap"> </span>/usr/local/lib/lua/5.1/socket/core.so: undefined symbol: lua_pcall</font></div></div></div></div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 stack traceback:</font></div></div></div></div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 <span style="white-space:pre-wrap"> </span>[C]: in ?</font></div></div></div></div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 <span style="white-space:pre-wrap"> </span>[C]: in function require</font></div></div></div></div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 <span style="white-space:pre-wrap"> </span>/usr/local/share/lua/5.1/socket.lua:12: in main chunk</font></div></div></div></div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 <span style="white-space:pre-wrap"> </span>[C]: in function require</font></div></div></div></div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 <span style="white-space:pre-wrap"> </span>/usr/local/share/lua/5.1/socket/http.lua:10: in main chunk</font></div></div></div></div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 <span style="white-space:pre-wrap"> </span>[C]: in function require</font></div></div></div></div><div><div><div><div><font face="times new roman, serif">09802b39-524f-4011-ada7-418e6a870248 <span style="white-space:pre-wrap"> </span>/usr/share/freeswitch/scripts/test.lua:3: in main chunk</font></div></div></div></div></blockquote><div><div><div><br></div></div><div><br></div><div>The lua script is:</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><font face="times new roman, serif">local http = require "socket.http";</font></div></div></div><div><div><div><font face="times new roman, serif"><br></font></div></div></div><div><div><div><font face="times new roman, serif">local req_url = "<a href="http://localhost/" target="_blank">http://localhost/</a>"</font></div></div></div><div><div><div><font face="times new roman, serif"><br></font></div></div></div><div><div><div><font face="times new roman, serif">http.request{</font></div></div></div><div><div><div><font face="times new roman, serif"> url = req_url,</font></div></div></div><div><div><div><font face="times new roman, serif"> method = "POST"</font></div></div></div><div><div><div><font face="times new roman, serif">}</font></div></div></div></blockquote><div><div><br></div><div><br></div><div>I tried several tutorials and several configurations:</div><div><br></div><div><ul><li><a href="https://freeswitch.org/confluence/display/FREESWITCH/Installing+LuaSocket" target="_blank">https://freeswitch.org/confluence/display/FREESWITCH/Installing+LuaSocket</a><br></li><li><a href="https://freeswitch.org/confluence/display/FREESWITCH/Third+Party+Libraries" target="_blank">https://freeswitch.org/confluence/display/FREESWITCH/Third+Party+Libraries</a> with <a href="https://luarocks.org/modules/jakeg/lua-requests" target="_blank"> https://luarocks.org/modules/jakeg/lua-requests</a><br></li></ul><div>And some other things that I do not remember but always fail for some "undefined symbol".</div></div></div><div><br></div><div>Any ideas? Thanks!</div><div><br></div><div>José D.</div></div></div></div>
_________________________________________________________________________<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a></blockquote></div>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br></blockquote></div><br></div></div></div></div>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
_________________________________________________________________________<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a></blockquote></div>