From 261477ba86d8305d8bea0d9aaa7099f840d5b21a Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 21 Apr 2025 16:34:54 +0800 Subject: [PATCH] fix --- apps/iot/src/iot_app.erl | 2 +- apps/iot/src/iot_sup.erl | 4 ++-- apps/iot/src/websocket/tcp_channel.erl | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/iot/src/iot_app.erl b/apps/iot/src/iot_app.erl index eccd6c4..40f8c8d 100644 --- a/apps/iot/src/iot_app.erl +++ b/apps/iot/src/iot_app.erl @@ -37,7 +37,7 @@ start_tcp_server() -> binary, {reuseaddr, true}, {active, false}, - {packet, 2}, + {packet, 4}, {nodelay, false}, {backlog, Backlog} ]}, diff --git a/apps/iot/src/iot_sup.erl b/apps/iot/src/iot_sup.erl index c644a48..04c6318 100644 --- a/apps/iot/src/iot_sup.erl +++ b/apps/iot/src/iot_sup.erl @@ -27,7 +27,7 @@ start_link() -> %% modules => modules()} % optional init([]) -> SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600}, - Specs = [ + Specs0 = [ #{ id => 'iot_device_sup', start => {'iot_device_sup', start_link, []}, @@ -47,7 +47,7 @@ init([]) -> } ], - {ok, {SupFlags, pools() ++ Specs}}. + {ok, {SupFlags, pools() ++ []}}. %% internal functions diff --git a/apps/iot/src/websocket/tcp_channel.erl b/apps/iot/src/websocket/tcp_channel.erl index c661153..ec6923d 100644 --- a/apps/iot/src/websocket/tcp_channel.erl +++ b/apps/iot/src/websocket/tcp_channel.erl @@ -157,6 +157,13 @@ handle_info({binary, <>}, St {ok, State#state{inflight = NInflight}} end; +handle_info({tcp, Socket, Data}, State = #state{transport = Transport, socket = Socket}) -> + lager:debug("[ws_channel] socket: ~p, get a message: ~p", [Socket, Data]), + + Transport:send(Socket, <<"hello world reply">>), + + {noreply, State}; + handle_info(Info, State) -> lager:error("[ws_channel] get a unknown message: ~p, channel will closed", [Info]), {stop, State};