Openresty websocket: Could not decode a text frame as UTF-8.


We use lua-resty-websocket to create websocket server:

https://github.com/openresty/lua-resty-websocket

				local st9 = splitByChunk(content,1024*32)
				for j1,j2 in pairs(st9) do				 
					local bytes, err = wb:send_text(j2)
					
					if err then
						ngx.log(ngx.ERR, 'err:'..err)
					end
				
				end

Solution: don’t use send_text, should use send_binary

				local st9 = splitByChunk(content,1024*32)
				for j1,j2 in pairs(st9) do				 
					local bytes, err = wb:send_binary(j2)
					
					if err then
						ngx.log(ngx.ERR, 'err:'..err)
					end
				
				end

Leave a Reply