ANN: dmc_websockets - WebSocket module for Corona SDK

Seeing what’s happening on the server side now.  Websocket opens and immediately closes.  The version number is not the issue.  Connection is not persisting.

a couple of days ago i pushed a fix for that error “attempt to index local ‘params’ (a string value)” – not sure when you last updated from github.

also on github near the top of the ReadMe i have listed a couple of ways you can PM me. you can use one of them to send me a zip of your code. i’d like to get you to a point where the connection is stable (or find out why it’s not), then you can continue your work from there.

thanks, dmc

Downloaded and installed your latest version.  Looks like that did it.  

Encoded and sent a JSON string and received a JSON string back.  Server side Java websocket persisting now as well.

Important step forward.  Thanks for all your support.  Will keep you posted.

Output as follows:

2014-08-17 15:27:40.542 Corona Simulator[5220:507] 

Copyright © 2009-2014  C o r o n a   L a b s   I n c .

2014-08-17 15:27:40.542 Corona Simulator[5220:507] Version: 3.0.0

2014-08-17 15:27:40.543 Corona Simulator[5220:507] Build: 2014.2393

2014-08-17 15:27:40.556 Corona Simulator[5220:507] Platform: iPhone / x86_64 / 10.9 / Intel HD Graphics 4000 OpenGL Engine / 2.1 INTEL-8.28.30 / 2014.2393

2014-08-17 15:27:40.628 Corona Simulator[5220:507] The file sandbox for this project is located at the following folder:

(/Users/scotsoutherland/Library/Application Support/Corona Simulator/Websocket-A7F64A150865B0DC24734D37DA1496ED)

2014-08-17 15:27:40.642 Corona Simulator[5220:507] Lua Patch::activating patch ‘table-pop’

2014-08-17 15:27:40.643 Corona Simulator[5220:507] Lua Patch::activating patch ‘string-format’

2014-08-17 15:27:40.649 Corona Simulator[5220:507] dmc_library:: Loading slower bitOp library

2014-08-17 15:27:40.753 Corona Simulator[5220:507] {“type”:“VersionMessage”,“fields”:{“version”:“NetLogo 5.0.4”}}

2014-08-17 15:27:40.754 Corona Simulator[5220:507] Received event: ONOPEN

2014-08-17 15:27:40.754 Corona Simulator[5220:507] BufferErrorFactory Read surpasses buffer size

2014-08-17 15:27:40.764 Corona Simulator[5220:507] Received event: ONMESSAGE

2014-08-17 15:27:40.765 Corona Simulator[5220:507] {“type”:“VersionMessage”,“fields”:{“version”:“NetLogo 5.0.4”}} text

2014-08-17 15:27:40.765 Corona Simulator[5220:507] BufferErrorFactory Read surpasses buffer size

Hello,

My app works with websockets on corona simulator, but I soon as I build it and launch it on my iPhone6, I have the following error messages :

Oct 2 16:16:09 iPhone-de-olivier myapp[2241] \<Warning\>: Platform: iPhone / iPhone7,2 / 8.0.2 / Apple A8 GPU / OpenGL ES 2.0 Apple A8 GPU - 50.5.1 / 2014.2393 Oct 2 16:16:09 iPhone-de-olivier myapp[2241] \<Warning\>: Lua Patch::activating patch 'table-pop' Oct 2 16:16:09 iPhone-de-olivier myapp[2241] \<Warning\>: Lua Patch::activating patch 'string-format' Oct 2 16:16:09 iPhone-de-olivier myapp[2241] \<Warning\>: Runtime error /Library/WebServer/Documents/myapp/mobile/dmc\_corona/dmc\_websockets.lua:136: module 'dmc\_sockets' not found in archive: /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/ module 'dmc\_sockets' not found:resource (dmc\_sockets.lu) does not exist in archive no field package.preload['dmc\_sockets'] no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.lua' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.lua' no file './dmc\_sockets.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.so'dmc\_sockets /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona /Library/WebServer/Documents/myapp/mobile/dmc\_corona/dmc\_sockets.lua:130: module 'dmc\_sockets.async\_tcp' not found in archive: /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/ module 'dmc\_sockets.async\_tcp' not found:resource (dmc\_sockets.async\_tcp.lu) does not exist in archive no field package.preload['dmc\_sockets.async\_tcp'] no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.async\_tcp.lua' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.async\_tcp.lua' no file './dmc\_sockets.async\_tcp.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.async\_tcp.so' no file './dmc\_sockets.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.so'dmc\_sockets.async\_tcp /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona /Library/WebServer/Documents/myapp/mobile/dmc\_corona/dmc\_sockets/async\_tcp.lua:53: module 'plugin.openssl' not found in archive: /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/ module 'plugin.openssl' not found:resource (plugin.openssl.lu) does not exist in archive no field package.preload['plugin.openssl'] no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/plugin.openssl.lua' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/plugin.openssl.lua' no file './plugin.openssl.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/plugin.openssl.so' no file './plugin.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/plugin.so'plugin.openssl /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona module 'dmc\_corona.plugin.openssl' not found:resource (dmc\_corona.plugin.openssl.lu) does not exist in archive no field package.preload['dmc\_corona.plugin.openssl'] no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona.plugin.openssl.lua' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona.plugin.openssl.lua' no file './dmc\_corona.plugin.openssl.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona.plugin.openssl.so' no file './dmc\_corona.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona.so'dmc\_corona.plugin.openssl stack traceback: [C]: in function 'error' /Library/WebServer/Documents/myapp/mobile/dmc\_corona\_boot.lua:421: in function 'require' /Library/WebServer/Documents/myapp/mobile/dmc\_corona/dmc\_websockets.lua:136: in main chunk [C]: in function 'require' ?: in function \<?:803\> (tail call): ? /Library/WebServer/Documents/myapp/mobile/main.lua:1: in main chunk

It occurs with the one and only require line :

local WebSockets = require ‘dmc_corona.dmc_websockets’

Is this a bug, or is there anything I may have done wrong ? (it works very well on simulator).

Thanks,

Olivier

hi Olivier, thanks for putting this on github. i’m just going to continue this over there, but:

one thing i notice from the traceback is that the open SSL library isn’t getting loaded. that comes from Corona Labs itself and is imported using the build.settings file. looking at the ‘echo’ example, it looks like the import for the SSL lib is missing from the build.settings file. :frowning: i will update the example.

for now, you can look at the the settings file for the ‘pusher’ example and use that instead.

Thanks for your answer.

Unfortunately, openssl is a plugin only available for PRO subscribers. Is there a way not to use this plugin in websockets ?

Thanks.

Hey dmc,

Just posting to verify that I was successful in reverse engineering the NetLogo Hubnet Protocol through the websocket.  We can now connect with NetLogo models via the Hubnet-Web extension.

Thanks for your help and your great work.

Best,

–Scot

hey Scot,

that’s fantastic news ! i’m glad to hear that your project is going well. thanks for the kudos, too. :slight_smile:

cheers, dmc

Hello,

My app works with websockets on corona simulator, but I soon as I build it and launch it on my iPhone6, I have the following error messages :

Oct 2 16:16:09 iPhone-de-olivier myapp[2241] \<Warning\>: Platform: iPhone / iPhone7,2 / 8.0.2 / Apple A8 GPU / OpenGL ES 2.0 Apple A8 GPU - 50.5.1 / 2014.2393 Oct 2 16:16:09 iPhone-de-olivier myapp[2241] \<Warning\>: Lua Patch::activating patch 'table-pop' Oct 2 16:16:09 iPhone-de-olivier myapp[2241] \<Warning\>: Lua Patch::activating patch 'string-format' Oct 2 16:16:09 iPhone-de-olivier myapp[2241] \<Warning\>: Runtime error /Library/WebServer/Documents/myapp/mobile/dmc\_corona/dmc\_websockets.lua:136: module 'dmc\_sockets' not found in archive: /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/ module 'dmc\_sockets' not found:resource (dmc\_sockets.lu) does not exist in archive no field package.preload['dmc\_sockets'] no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.lua' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.lua' no file './dmc\_sockets.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.so'dmc\_sockets /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona /Library/WebServer/Documents/myapp/mobile/dmc\_corona/dmc\_sockets.lua:130: module 'dmc\_sockets.async\_tcp' not found in archive: /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/ module 'dmc\_sockets.async\_tcp' not found:resource (dmc\_sockets.async\_tcp.lu) does not exist in archive no field package.preload['dmc\_sockets.async\_tcp'] no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.async\_tcp.lua' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.async\_tcp.lua' no file './dmc\_sockets.async\_tcp.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.async\_tcp.so' no file './dmc\_sockets.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_sockets.so'dmc\_sockets.async\_tcp /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona /Library/WebServer/Documents/myapp/mobile/dmc\_corona/dmc\_sockets/async\_tcp.lua:53: module 'plugin.openssl' not found in archive: /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/ module 'plugin.openssl' not found:resource (plugin.openssl.lu) does not exist in archive no field package.preload['plugin.openssl'] no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/plugin.openssl.lua' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/plugin.openssl.lua' no file './plugin.openssl.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/plugin.openssl.so' no file './plugin.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/plugin.so'plugin.openssl /private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona module 'dmc\_corona.plugin.openssl' not found:resource (dmc\_corona.plugin.openssl.lu) does not exist in archive no field package.preload['dmc\_corona.plugin.openssl'] no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona.plugin.openssl.lua' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona.plugin.openssl.lua' no file './dmc\_corona.plugin.openssl.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona.plugin.openssl.so' no file './dmc\_corona.so' no file '/private/var/mobile/Containers/Bundle/Application/AC5F1AFF-16AE-4CA2-BFF8-176AFDD3C516/myapp.app/dmc\_corona.so'dmc\_corona.plugin.openssl stack traceback: [C]: in function 'error' /Library/WebServer/Documents/myapp/mobile/dmc\_corona\_boot.lua:421: in function 'require' /Library/WebServer/Documents/myapp/mobile/dmc\_corona/dmc\_websockets.lua:136: in main chunk [C]: in function 'require' ?: in function \<?:803\> (tail call): ? /Library/WebServer/Documents/myapp/mobile/main.lua:1: in main chunk

It occurs with the one and only require line :

local WebSockets = require ‘dmc_corona.dmc_websockets’

Is this a bug, or is there anything I may have done wrong ? (it works very well on simulator).

Thanks,

Olivier

hi Olivier, thanks for putting this on github. i’m just going to continue this over there, but:

one thing i notice from the traceback is that the open SSL library isn’t getting loaded. that comes from Corona Labs itself and is imported using the build.settings file. looking at the ‘echo’ example, it looks like the import for the SSL lib is missing from the build.settings file. :frowning: i will update the example.

for now, you can look at the the settings file for the ‘pusher’ example and use that instead.

Thanks for your answer.

Unfortunately, openssl is a plugin only available for PRO subscribers. Is there a way not to use this plugin in websockets ?

Thanks.

the library has been updated to not autoload the SSL plugin at the start, only when accessing a secure URL.

the library has been updated to not autoload the SSL plugin at the start, only when accessing a secure URL.

Note I have this working with TSL now, fix is documented here: