ngx_lua_websocket server實現
local server = require"resty.websocket.server"
local wb,err = server:new{
timeout = 10000,
max_payload_len = 65535,
}
if not wb then
local data,typ,err = wb:recv_frame()
if not data then
if not string.find(err,'timeout',1,true) then
ngx.log(ngx.ERR,"failed to receive a frame1",err)
return ngx.exit(444)
end
end
if typ == "clese" then
local code = err
local bytes, err = wb:send_close(1000,"enough,enough!")
if not bytes then
ngx.log(ngx.ERR,"failed to send close frame,",err)
return
end
ngx.log(ngx.INFO,"closing with status code",code," with message ",data)
return
end
local wb,err = server:new{
timeout = 10000,
max_payload_len = 65535,
}
if not wb then
ngx.log(ngx.ERR,"failed to create websocket server",err)
return ngx.exit(444)end
local data,typ,err = wb:recv_frame()
if not data then
if not string.find(err,'timeout',1,true) then
ngx.log(ngx.ERR,"failed to receive a frame1",err)
return ngx.exit(444)
end
end
if typ == "clese" then
local code = err
local bytes, err = wb:send_close(1000,"enough,enough!")
if not bytes then
ngx.log(ngx.ERR,"failed to send close frame,",err)
return
end
ngx.log(ngx.INFO,"closing with status code",code," with message ",data)
return
end
相關文章
- 實現自己的http serverHTTPServer
- 如何實現一個Web ServerWebServer
- Blazor Server完美實現Cookie Authorization and AuthenticationBlazorServerCookie
- [SQL Server]分頁功能的實現SQLServer
- Day3_beast實現http serverASTHTTPServer
- Spring Authorization Server 實現授權中心SpringServer
- 配置PXE Server實現網路啟動Server
- SQL Server--實現 Limit m, n 的功能SQLServerMIT
- SQL Server資料庫實現負載均衡SQLServer資料庫負載
- SQL Server 實現行列(縱橫表)轉換SQLServer
- SQL Server相似比較演算法實現SQLServer演算法
- Sql Server 使用CTE實現遞迴查詢SQLServer遞迴
- 當微信小程式遇上TensorFlow:Server端實現微信小程式Server
- Holer實現外網訪問本地Apache HTTP ServerApacheHTTPServer
- 使用HazelCast實現Spring Config Server配置ASTSpringServer
- sql?server?累計求和實現程式碼簏攔SQLServer
- SQL Server資料庫的簡單實現方法SQLServer資料庫
- 在Linux系統下實現Server Push(轉)LinuxServer
- 在SQL SERVER中實現RSA加密演算法SQLServer加密演算法
- PostgreSQL、Oracle/MySQL和SQL Server的MVCC實現原理方式OracleMySqlServerMVC
- SQL Server跨庫跨伺服器訪問實現SQLServer伺服器
- 如何在SQL Server中實現 Limit m,n 的功能SQLServerMIT
- KCSQL SERVER實現連線與合併查詢dinSQLServer
- Go Web學習(1)——標準庫http實現serverGoWebHTTPServer
- 《初識TCP》iOS、macOS實現socket client與socket serverTCPiOSMacclientServer
- SQL Server 2005快速Web分頁的實現SQLServerWeb
- 實現SQL Server 2008資料壓縮SQLServer
- SQL Server實現Standby --日誌傳送(Log Shipping)SQLServer
- 巧用SQL Server(Ranking)實現view的排序功能SQLServerView排序
- 在SQL SERVER中實現事務的部分回滾SQLServer
- 通過SQL SERVER遠端上傳檔案的實現SQLServer
- SQL Server連線VFP資料庫的實現 (轉)SQLServer資料庫
- SQL Server連線ACCESS資料庫的實現 (轉)SQLServer資料庫
- MySQL server5.7版出現server failedMySqlServerAI
- onvif規範的實現:server端Discovery實現,通過OnvifTestTool12.06測試Server
- SQL Server 2005 實現資料庫快取依賴的實現步驟整理SQLServer資料庫快取
- Vue 之青銅 I ⭐⭐⭐[用 webpack-dev-server 實現修改實時生效]VueWebdevServer
- SQL Server雙機熱備之釋出、訂閱實現實時同步SQLServer