fix issue #189 - Websocket(SSL) cannot work for emqttd_net:peername error

This commit is contained in:
Feng 2015-07-10 10:48:09 +08:00
parent f4a5760dbd
commit e59232c2ab
1 changed files with 1 additions and 2 deletions

View File

@ -102,8 +102,7 @@ reset_parser(State = #wsocket_state{packet_opts = PktOpts}) ->
init([WsPid, Req, ReplyChannel, PktOpts]) -> init([WsPid, Req, ReplyChannel, PktOpts]) ->
process_flag(trap_exit, true), process_flag(trap_exit, true),
Socket = Req:get(socket), {ok, Peername} = Req:get(peername),
{ok, Peername} = emqttd_net:peername(Socket),
SendFun = fun(Payload) -> ReplyChannel({binary, Payload}) end, SendFun = fun(Payload) -> ReplyChannel({binary, Payload}) end,
ProtoState = emqttd_protocol:init(Peername, SendFun, PktOpts), ProtoState = emqttd_protocol:init(Peername, SendFun, PktOpts),
{ok, #client_state{ws_pid = WsPid, request = Req, proto_state = ProtoState}}. {ok, #client_state{ws_pid = WsPid, request = Req, proto_state = ProtoState}}.