Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

when use ngx.socket.tcp, the function sslhandshake is a nil #19

Open
oliveryunchang opened this issue Jul 12, 2017 · 5 comments
Open

when use ngx.socket.tcp, the function sslhandshake is a nil #19

oliveryunchang opened this issue Jul 12, 2017 · 5 comments

Comments

@oliveryunchang
Copy link

oliveryunchang commented Jul 12, 2017

when i use (tcpsock:sslhandshake)[https://github.com/openresty/lua-nginx-module#tcpsocksslhandshake], got a error. the error log is

2017/07/12 13:02:59 [error] 104940#0: *28 lua entry thread aborted: runtime error: content_by_lua(nginx.conf:137):10: attempt to call field 'sslhandshake' (a nil value)
stack traceback:
coroutine 0:
        content_by_lua(nginx.conf:137): in function <content_by_lua(nginx.conf:137):1>, client: 127.0.0.1, server: www.test.com, request: "GET /tcp HTTP/1.1", host: "localhost:9001"

and the code is

location = /tcp {
 resolver 8.8.8.8;
 content_by_lua '
     local sock = ngx.socket.tcp()
     local ok, err = sock:connect("www.baidu.com", 80)
     if not ok then
        ngx.say("failed to connect to baidu: ", err)
         return
     end
     sock:settimeout(60)
     sock:setkeepalive(40)
     sock:sslhandshake(nil, "www.baidu.com",false)
     ngx.say("successfully connected to baidu!")
     sock:close()
 ';
}
@yejingx
Copy link
Contributor

yejingx commented Jul 12, 2017

Which lua-nginx-module version do you use?

@oliveryunchang
Copy link
Author

test on the latest slardar, lua-nginx-module version is 0.10.6rc1

@yejingx
Copy link
Contributor

yejingx commented Jul 13, 2017

@0904681074 You must compile Nginx with openssl before you can use tcpsocket:sslhandshake. You can add --with-openssl or set your own openssl path here.

@oliveryunchang
Copy link
Author

Thanks a lot!

@oliveryunchang
Copy link
Author

--with-http_ssl_module or --with-openssl=openssl_path

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants