luaproc: Can not load socket module from process

I try to require the socket module from within a luaproc process but I just get:

close lua\_State (error: main.lua:8: module 'socket' not found: no field package.preload['socket'] no file '/Users/jocke/Library/Application Support/Corona/Simulator/Plugins/socket.lua' no file 'socket.lua' no file '/Applications/CoronaSDK-2992/Corona Simulator.app/Contents/Resources/socket.lua' no file '/Users/jocke/Library/Application Support/Corona/Simulator/Plugins/socket.dylib' no file './socket.dylib' no file '/Applications/CoronaSDK-2992/Corona Simulator.app/Contents/Resources/socket.dylib')

My test main.lua looks like this:

local luaproc = require "plugin.luaproc" luaproc.setnumworkers(1) local started =   luaproc.newproc(     function()       local socket = require "socket"     end) print(started)

I must be missing something here. Can you see what?

Cheers

/Joakim

Hi Joakim.

Unfortunately luasocket and some other libraries are loaded from package.preload (which you see listed in the error), which implies Corona is doing something special. Looking around, I don’t see the libraries located anywhere, so I suspect they might be embedded in the Corona player (if so, this might be all there is to “the something special”, but I can’t be sure). Thus I have no real way to inject them into the new processes’ preload table.  :frowning: Maybe I could file a request to add this to Enterprise for the “safe” libraries (i.e. things that, at least I assume, are basically self-contained or stateless) so I could add this.

Since you have Enterprise yourself, maybe you could make your own build of luasocket? (If so, might be best to give this one a slightly different name to avoid conflicts.) At the moment I can’t think of a better solution.

That was sad. The luaproc developers mentioned that luaproc+luasocket should be OK as long as you avoid to trigger DNS lookups. (DNS lookups in luaproc processes trigger a memory error for some reason it seems.)

With that in mind I wrote a HTTP Proxy <-> SOCKSv5 bridge with luaproc+luasocket  even though the socket loading failed. Optimistic about that this would solve itself later. :slight_smile:

Hmm, I could build my own luasocket plugin with a new name but it feels like a daunting task. I will postpone this work until a later stage and use my slow solution for the time being.

Thanks for your help.

Cheers

/Joakim

I’m looking into whether I can get some support into Enterprise. If so, I’ll push it into the plugin as soon as possible. Sorry for these growing pains.  :slight_smile:

Thanks!! Luasocket+luaproc is a strong combination.

Hi,

Will you be able get this support into Enterprise before the end of the year? If not do you have a planned release date? Even an approximate date?

 I have found even more use for the luaproc+socket combo. Sitting on my hands. :slight_smile:

Cheers

/Joakim

I thought a function that I needed was missing from Lua’s C API, but it seems like I was mistaken. I’ll investigate today.

I’ve been playing around with some new features (see the various WIP stuff https://ggcrunchy.github.io/corona-plugin-docs/DOCS/luaproc/api.html), so it might still be a couple days to make sure it all works (in particular, iOS builds depend on an older C++ runtime and it’s been quite a chore to integrate somewhat modern stuff).

After a couple hours I seem to have things rigged up, preloading the libraries I’m assuming are safe (so nothing that originates from the SDK). The list is at the docs, in newproc.

I’ll try to get at least the desktop builds up in the next day or so.

Great news indeed. Thanks for your effort!

Cheers

/Joakim

If all went well, this should be up shortly (for Windows and Mac). I’ll let you know when I get the remaining builds up, though it might be another few days. (I’m using a shared Mac, and lately that means trying to do so over a remote connection from home when everybody’s done for the day. Which is a slow and demoralizing process.  :P)

It works!!! Unless I do something wrong wrong. :slight_smile:

Thank you very much

/Joakim

A short question. Where can I download libplugin.luaproc.so etc for my tries with Corona Enterprise?

Cheers

/Joakim

Hi Joakim. In the short term you could PM me for binaries.

I do have some bugfixes and later some improvements planned (moving iOS to 8 and libc++, followed by getting all the WIP features mentioned in the docs into order), so this might be a moving target for a while.  :) I don’t know if things are set up yet to automate the process.