dmccuskey / DMC-Corona-Library

Development library for Corona SDK
docs.davidmccuskey.com/
82 stars 27 forks source link

Crash when using wss:// secure connection -- nil pointer to _socket:setoption function #30

Closed n8sabes closed 9 years ago

n8sabes commented 9 years ago

dmc_corona-2.x

When using a wss:// secure connection for either websocket or wamp connection, async_tcp.la:240 crashes with a nil pointer. Works fine with ws://.

Runtime error /Users/n8/Development/Project_Name/dmc_corona/dmc_sockets/async_tcp.lua:523: /Users/n8/Development/Project_Name/dmc_corona/dmc_sockets/async_tcp.lua:240: attempt to call method 'setoption' (a nil value)

                self._socket:setoption( 'keepalive', true )
                self._socket:setoption( 'tcp-nodelay', true )

self._socket is valid at time of execution. build.settings is including the ssl plugin. ["plugin.openssl"] = { publisherId = "com.coronalabs", },

Why is this happening, is there a fix, or workaround?

dmccuskey commented 9 years ago

i don't know offhand why that's happening.

i just checked docs, and seems like there are new settings listed for the build.settings file. docs don't mention defaults, so i don't know what's necessary, etc.: https://docs.coronalabs.com/plugin/openssl/index.html

i assume you're using a fairly recent version of Corona SDK. so i'd say start by adding to your build.settings and see how that goes. being that their are new settings, i'm wondering if the library has been updated (and perhaps changed API?). i'd print out the entirety of self._socket to see what properties that object has.

temporarily you could also wrap those lines with a check for setoption so the code doesn't blow up.

n8sabes commented 9 years ago

I made those two lines conditional last night and got it working on the Corona Simulator (only). The self._socket table is valid but the setoption() function is nil.

dmc_websockets does'n't seem work when deployed to a real iOS device right now -- nor does dmc_wamp due to its dependency on dmc_websockets. Neither ws:// non-secure via CoronaSDK Builder, nor wss:// TLS secure via Corona Enterprise via current Xcode 7 (7A220 ) work when deployed. No build errors or diagnostics reported that I can find -- just a deaf channel.

I have reached out to the Corona guys for their input.

Are you able to build anything with dmc_wamp and have it run on a real iOS device (not just the Corona Simulator)?

If you have a sample Xcode 7 project with current branches I would truly appreciate referencing it to figure out what's going wrong, or what I'm missing.

dmccuskey commented 9 years ago

i can't remember if i had deployed websockets or wamp on a device, though seems like i would have at one point or another. my project for which those were created is still in development so coding was mostly simulator. i haven't touched it in awhile to remember for sure. however, i know that others have deployed on device. for example, the websocket Pusher example was one i put together for someone and it uses TLS, sending in the type of secure connection in the setup.

basically it comes down to a socket issue. the openssl lib just wraps a socket and once it's connected everything else is transparent. so if you can get a socket connecting and sharing info, then the rest should just work. of course the Corona example was my starting point for research: https://github.com/coronalabs/plugins-sample-openssl/blob/master/luasec/main.lua

i never used Corona Enterprise, so i can't help with an Xcode project.

in short, i'd check:

also, i have to mention that i've been evaluating another framework to use for my mobile development. i'm on board with my new direction, so at this point have halted any work with Corona SDK or my libs.

n8sabes commented 9 years ago

Thank you. I have both ws:// non-secure and wss:// TLS secure working in the simulator so I know the client code works correctly with my golang WAMP broker service.

I'll keep looking at it and hopefully the Corona folks can help resolve the web socket / openssl plugin issue.

dmccuskey commented 9 years ago

sounds good. good luck !

florindumitru commented 7 years ago

No fix for that yet !??