1

I install lua socket module by run the following command:

apt install  lua-socket

When use local socket = require('socket') in OpenResty config, I got the following error:

module 'socket' not found:
no field package.preload['socket']
no file '/usr/local/openresty/site/lualib/socket.ljbc'
no file '/usr/local/openresty/site/lualib/socket/init.ljbc'
no file '/usr/local/openresty/lualib/socket.ljbc'
no file '/usr/local/openresty/lualib/socket/init.ljbc'
no file '/usr/local/openresty/site/lualib/socket.lua'
no file '/usr/local/openresty/site/lualib/socket/init.lua'
no file '/usr/local/openresty/lualib/socket.lua'
no file '/usr/local/openresty/lualib/socket/init.lua'
no file './socket.lua'
no file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/socket.lua'
no file '/usr/local/share/lua/5.1/socket.lua'
no file '/usr/local/share/lua/5.1/socket/init.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/socket.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/socket/init.lua'
no file '/usr/local/openresty/site/lualib/socket.so'
no file '/usr/local/openresty/lualib/socket.so'
no file './socket.so'
no file '/usr/local/lib/lua/5.1/socket.so'
no file '/usr/local/openresty/luajit/lib/lua/5.1/socket.so'
no file '/usr/local/lib/lua/5.1/loadall.so'

OpenResty Version: 1.19.3.1

How can use socket module in OpenResty?

Ren
  • 2,852
  • 2
  • 23
  • 45

1 Answers1

0

I think https://github.com/thibaultCha/lua-resty-socket should be used in openresty ecosystem.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 31 '22 at 07:59
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31889323) – mc-user Jun 03 '22 at 13:31