websocket压测工具(itcp wed components 是什么软件)

本文目录
itcp wed components 是什么软件
netty v3.9.4
***隐藏网址***
websocket到现在为止,已经有多个版本,netty有相应的对应类,这部分处理一般不需要人工干预。
如果运行正常的话,会在页面的文本框中显示1-20记数。
可以通过firefox或chrome的开发人员工具,显看浏览器与服务器的交互。
主要明茄是HttpServerChannelHandler2,加旁槐灶了些注释和少量debug代码。
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
***隐藏网址***
import java.util.List;
import java.util.Map;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
public class HttpServerChannelHandler2 extends SimpleChannelHandler{
public static boolean debug = true;
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
Channel ch = e.getChannel();
Object msg = e.getMessage();
if(debug){
System.out.println("---------------");
System.out.println("message: "+msg.getClass());
}
***隐藏网址***
***隐藏网址***
if(msg instanceof HttpRequest){
processHttpRequest(ch, (HttpRequest)msg);
}else if(msg instanceof WebSocketFrame){
processWebsocketRequest(ch,(WebSocketFrame)msg);
}else{
//未处理的请求类型
}
}
//这个方法:
***隐藏网址***
//2.屏蔽掉非websocket握手请求
void processHttpRequest(Channel channel,HttpRequest request){
HttpHeaders headers = request.headers();
if(debug){
List《Map.Entry《String,String》》 ls = headers.entries();
for(Map.Entry《String,String》 i: ls){
System.out.println("header "+i.getKey()+":"+i.getValue());
}
}
//屏蔽掉非websocket握手请求
***隐藏网址***
if(!HttpMethod.GET.equals(request.getMethod())
|| !"websocket".equalsIgnoreCase(headers.get("Upgrade"))){
DefaultHttpResponse resp = new DefaultHttpResponse(
HttpVersion.HTTP_1_1,
HttpResponseStatus.BAD_REQUEST);
channel.write(resp);
channel.close();
return;
}
WebSocketServerHandshakerFactory wsShakerFactory = new WebSocketServerHandshakerFactory(
"ws://"+request.headers().get(HttpHeaders.Names.HOST),
null,false );
WebSocketServerHandshaker wsShakerHandler = wsShakerFactory.newHandshaker(request);
if(null==wsShakerHandler){
//无法处理的websocket版本
wsShakerFactory.sendUnsupportedWebSocketVersionResponse(channel);
}else{
//向客户端发送websocket握手,完成握手
//客户端收到的状态是101 sitching protocol
wsShakerHandler.handshake(channel, request);
}
}
//websocket通信
void processWebsocketRequest(Channel channel, WebSocketFrame request){
if(request instanceof CloseWebSocketFrame){
channel.close();
}else if(request instanceof PingWebSocketFrame){
channel.write(new PongWebSocketFrame(request.getBinaryData()));
}else if(request instanceof TextWebSocketFrame){
//这个地方 可以根据需求,加上一些业务逻辑
TextWebSocketFrame txtReq = (TextWebSocketFrame) request;
if(debug){ System.out.println("txtReq:"+txtReq.getText());}
//向ws客户端发送多个响应
for(int i=1; i《=20; i++){
channel.write(new TextWebSocketFrame(""+i));
try{Thread.sleep(300);}catch(Exception ex){}
}
}else{
//WebSocketFrame还有一些
}
}
}
其他类跟网上的差不多:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
***隐藏网址***
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
public class HttpServer implements Runnable{
int port = 80;
public HttpServer(int port){
this.port = port;
}
@Override
public void run() {
ServerBootstrap b = new ServerBootstrap(
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
b.setPipelineFactory(new HttpServerChannelPipelineFactory());
b.setOption("child.tcpNoDelay", true);
b.setOption("child.keepAlive", true);
b.bind(new InetSocketAddress(port));
}
public static void main(String args){
new HttpServer(80).run();
}
}
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
***隐藏网址***
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
***隐藏网址***
***隐藏网址***
***隐藏网址***
***隐藏网址***
public class HttpServerChannelPipelineFactory implements ChannelPipelineFactory {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline cp = Channels.pipeline();
cp.addLast("decoder", new HttpRequestDecoder());
// cp.addLast("decoder", new WebSocket00FrameDecoder());
cp.addLast("encoder", new HttpResponseEncoder());
// cp.addLast("downhandler", new HttpServerDownstreamHandler());
// cp.addLast("uphandler", new HttpServerUpstreamHandler());
cp.addLast("handler", new HttpServerChannelHandler2());
return cp;
}
}
测试页面:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
《html》
《head》
《script 》
function connect1(){
alert(’connect1’);
var ta = document.getElementById(’responseText’);
var socket = new WebSocket(’ws://127.0.0.1/websocket’);
if (window.WebSocket) {
}else{
alert(’Your browser does not support Web Socket.’);
return;
}
socket.onopen = function(event) {
ta.value = "Web Socket opened!";
}
socket.onmessage = function(event) {
ta.value = event.data;
};
socket.onclose = function(event) {
ta.value = "Web Socket closed";
};
}
function connect() {
alert(’connect’);
var socket;
if (!window.WebSocket) {
window.WebSocket = window.MozWebSocket;
}
if (window.WebSocket) {
socket = new WebSocket("ws://127.0.0.1/websocket");
socket.onmessage = function(event) {
var ta = document.getElementById(’responseText’);
ta.value = event.data;
};
socket.onopen = function(event) {
var ta = document.getElementById(’responseText’);
ta.value = "Web Socket opened!";
socket.send(’hello’);
};
socket.onclose = function(event) {
var ta = document.getElementById(’responseText’);
ta.value = "Web Socket closed";
};
socket.onerror = function(event){
};
} else {
alert("Your browser does not support Web Socket.");
}
}
《/script》
《/head》
《body》
《input type="button" onclick="connect1()" value="ws connect1"/》 《br/》《br/》
《input type="button" onclick="connect()" value="ws connect"/》 《br/》《br/》
《input id="responseText" type="text" value="123456"/》
《/body》
《/html》
obswebsocket修改配置
要修改 OBS WebSocket 配置,可以按照以下步骤进行:
1. 打开 OBS Studio 软件,进入“工具”菜单,选择“WebSockets 服务器设置”。
2. 在弹出的对话框中,可以设置 WebSocket 的监听地址、端口号以及授权密码。默认情况下,WebSocket 监听地址为“localhost”,端口号为“4444”,授权密码为空。
3. 如果需要修改 WebSocket 的监听地址和端口号,可以在对应的文本框中进行修改,然后点击“应用”按钮保存设置。
4. 如果需要设置授权密码,可以在“密码”文本框中输入密码,然后点击“应用”按钮保存设置。注意,设置密码后,连接 WebSocket 时需要在连接请求中提供该密码,否则无法连接。
5. 修毁银改完成后,可以点击“确定”按钮关闭设置对话框。
需要注意的是,修改 WebSocket 配置可能会影响 OBS Studio 的使用和安全性,建议在进行修改前先备份原始配置文件,并谨慎操作。同时,如果需郑困要在 OBS Studio 中使用 WebSocket 功喊余念能,还需要在对应的插件或脚本中设置 WebSocket 连接参数,以便正确连接到 OBS WebSocket 服务器。

更多文章:
最全ascii码对照表汉字范围(汉字 ascii值得范围 字符编码为utf-8 求所有汉字的ascii值得范围)
2026年8月24日 12:00
个人述职报告ppt(简约彩色个人述职报告PPT模板最新怎么样)
2025年9月19日 22:30
pycharm安装labelme(Pycharm及python安装详细教程 python详细安装教程)
2025年9月28日 13:15
competition的中文意思(game,tournament,match和competition这四个词使用上的注意以及区分)
2025年12月19日 12:15
linuxvim全部删除(vim如何删除光标所在行后面的所有行)
2025年10月30日 16:30
rhino的trim怎么用(rhino中如何能切割不在同一平面的线)
2026年4月10日 11:30
firstfloor是几楼(为什么英国说的一楼,其实是中国和美国人说的二楼.)
2026年1月15日 13:00
dirty pair(李阳疯狂英语100个发音秘诀 字母歌歌词的翻译,不要 网页链接什么的,求直接写下来)
2026年8月13日 19:00
nginx实战反向代理(Nginx 最全操作——nginx反向代理(5))
2025年9月6日 23:45
sqlserver数据库名称是哪个(重命名SQLServer数据库的方法)
2025年9月30日 05:15
杰克琼斯旗下高端品牌叫什么(杰克琼斯和ONLY是不是一家公司的)
2026年7月11日 21:00
gpg error(cydia出现GPG error错误怎么办)
2025年10月26日 19:30






![在VC++中,tchar[]怎么转成string类型?c++ 关于getchar()函数](/static/images/nopic/3.jpg)





