Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
400cfbe2
Commit
400cfbe2
authored
Mar 13, 2021
by
Pavel Vainerman
Committed by
Pavel Vainerman
May 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[uwebsocket]: increased maxsend to 5000.
parent
8d26f08f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
12 deletions
+24
-12
UWebSocketGate.cc
extensions/UWebSocketGate/UWebSocketGate.cc
+14
-6
UWebSocketGate.h
extensions/UWebSocketGate/UWebSocketGate.h
+9
-5
start_fg.sh
extensions/UWebSocketGate/start_fg.sh
+1
-1
No files found.
extensions/UWebSocketGate/UWebSocketGate.cc
View file @
400cfbe2
...
@@ -83,6 +83,8 @@ UWebSocketGate::UWebSocketGate( uniset::ObjectId id, xmlNode* cnode, const strin
...
@@ -83,6 +83,8 @@ UWebSocketGate::UWebSocketGate( uniset::ObjectId id, xmlNode* cnode, const strin
wsMaxSend
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"max-send"
,
it
.
getProp
(
"wsMaxSend"
),
wsMaxSend
);
wsMaxSend
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"max-send"
,
it
.
getProp
(
"wsMaxSend"
),
wsMaxSend
);
wsMaxCmd
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"max-cmd"
,
it
.
getProp
(
"wsMaxCmd"
),
wsMaxCmd
);
wsMaxCmd
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"max-cmd"
,
it
.
getProp
(
"wsMaxCmd"
),
wsMaxCmd
);
mylog1
<<
myname
<<
"maxSend="
<<
wsMaxSend
<<
" maxCmd="
<<
wsMaxCmd
<<
endl
;
httpHost
=
conf
->
getArgParam
(
"--"
+
prefix
+
"httpserver-host"
,
"localhost"
);
httpHost
=
conf
->
getArgParam
(
"--"
+
prefix
+
"httpserver-host"
,
"localhost"
);
httpPort
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"httpserver-port"
,
8081
);
httpPort
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"httpserver-port"
,
8081
);
httpCORS_allow
=
conf
->
getArgParam
(
"--"
+
prefix
+
"httpserver-cors-allow"
,
"*"
);
httpCORS_allow
=
conf
->
getArgParam
(
"--"
+
prefix
+
"httpserver-cors-allow"
,
"*"
);
...
@@ -252,7 +254,7 @@ void UWebSocketGate::help_print()
...
@@ -252,7 +254,7 @@ void UWebSocketGate::help_print()
cout
<<
"--prefix-max num - Максимальное количество websocket-ов"
<<
endl
;
cout
<<
"--prefix-max num - Максимальное количество websocket-ов"
<<
endl
;
cout
<<
"--prefix-heartbeat-time msec - Период сердцебиения в соединении. По умолчанию: 3000 мсек"
<<
endl
;
cout
<<
"--prefix-heartbeat-time msec - Период сердцебиения в соединении. По умолчанию: 3000 мсек"
<<
endl
;
cout
<<
"--prefix-send-time msec - Период посылки сообщений. По умолчанию: 500 мсек"
<<
endl
;
cout
<<
"--prefix-send-time msec - Период посылки сообщений. По умолчанию: 500 мсек"
<<
endl
;
cout
<<
"--prefix-max-send num - Максимальное число сообщений посылаемых за один раз. По умолчанию:
2
00"
<<
endl
;
cout
<<
"--prefix-max-send num - Максимальное число сообщений посылаемых за один раз. По умолчанию:
50
00"
<<
endl
;
cout
<<
"--prefix-max-cmd num - Максимальное число команд обрабатываемых за один раз. По умолчанию: 200"
<<
endl
;
cout
<<
"--prefix-max-cmd num - Максимальное число команд обрабатываемых за один раз. По умолчанию: 200"
<<
endl
;
cout
<<
"http: "
<<
endl
;
cout
<<
"http: "
<<
endl
;
...
@@ -617,7 +619,7 @@ UWebSocketGate::UWebSocket::UWebSocket(Poco::Net::HTTPServerRequest* _req,
...
@@ -617,7 +619,7 @@ UWebSocketGate::UWebSocket::UWebSocket(Poco::Net::HTTPServerRequest* _req,
iosend
.
set
<
UWebSocketGate
::
UWebSocket
,
&
UWebSocketGate
::
UWebSocket
::
send
>
(
this
);
iosend
.
set
<
UWebSocketGate
::
UWebSocket
,
&
UWebSocketGate
::
UWebSocket
::
send
>
(
this
);
iorecv
.
set
<
UWebSocketGate
::
UWebSocket
,
&
UWebSocketGate
::
UWebSocket
::
read
>
(
this
);
iorecv
.
set
<
UWebSocketGate
::
UWebSocket
,
&
UWebSocketGate
::
UWebSocket
::
read
>
(
this
);
maxsize
=
maxsend
*
10
;
// пока так
maxsize
=
maxsend
*
Kbuf
;
setReceiveTimeout
(
uniset
::
PassiveTimer
::
millisecToPoco
(
recvTimeout
));
setReceiveTimeout
(
uniset
::
PassiveTimer
::
millisecToPoco
(
recvTimeout
));
setMaxPayloadSize
(
sizeof
(
rbuf
));
setMaxPayloadSize
(
sizeof
(
rbuf
));
...
@@ -748,7 +750,10 @@ void UWebSocketGate::UWebSocket::read( ev::io& io, int revents )
...
@@ -748,7 +750,10 @@ void UWebSocketGate::UWebSocket::read( ev::io& io, int revents )
}
}
if
(
(
flags
&
WebSocket
::
FRAME_OP_BITMASK
)
==
WebSocket
::
FRAME_OP_CLOSE
)
if
(
(
flags
&
WebSocket
::
FRAME_OP_BITMASK
)
==
WebSocket
::
FRAME_OP_CLOSE
)
{
term
();
return
;
return
;
}
if
(
n
==
sizeof
(
rbuf
)
)
if
(
n
==
sizeof
(
rbuf
)
)
{
{
...
@@ -853,7 +858,7 @@ void UWebSocketGate::UWebSocket::sensorInfo( const uniset::SensorMessage* sm )
...
@@ -853,7 +858,7 @@ void UWebSocketGate::UWebSocket::sensorInfo( const uniset::SensorMessage* sm )
if
(
jbuf
.
size
()
>
maxsize
)
if
(
jbuf
.
size
()
>
maxsize
)
{
{
mywarn
<<
req
->
clientAddress
().
toString
()
<<
" lost messages..."
<<
endl
;
mywarn
<<
req
->
clientAddress
().
toString
()
<<
" lost messages...
(maxsize="
<<
maxsize
<<
")
"
<<
endl
;
return
;
return
;
}
}
...
@@ -926,7 +931,7 @@ void UWebSocketGate::UWebSocket::sendShortResponse( sinfo& si )
...
@@ -926,7 +931,7 @@ void UWebSocketGate::UWebSocket::sendShortResponse( sinfo& si )
{
{
if
(
jbuf
.
size
()
>
maxsize
)
if
(
jbuf
.
size
()
>
maxsize
)
{
{
mywarn
<<
req
->
clientAddress
().
toString
()
<<
"
lost messages...
"
<<
endl
;
mywarn
<<
req
->
clientAddress
().
toString
()
<<
"
(sendShortResponse): lost messages (maxsize="
<<
maxsize
<<
")
"
<<
endl
;
return
;
return
;
}
}
...
@@ -942,7 +947,7 @@ void UWebSocketGate::UWebSocket::sendResponse( sinfo& si )
...
@@ -942,7 +947,7 @@ void UWebSocketGate::UWebSocket::sendResponse( sinfo& si )
if
(
jbuf
.
size
()
>
maxsize
)
if
(
jbuf
.
size
()
>
maxsize
)
{
{
mywarn
<<
req
->
clientAddress
().
toString
()
<<
"
lost messages..."
<<
endl
;
mywarn
<<
req
->
clientAddress
().
toString
()
<<
"
(sendResponse): lost messages (maxsize="
<<
maxsize
<<
")"
<<
endl
;
return
;
return
;
}
}
...
@@ -956,7 +961,7 @@ void UWebSocketGate::UWebSocket::sendError( const std::string& msg )
...
@@ -956,7 +961,7 @@ void UWebSocketGate::UWebSocket::sendError( const std::string& msg )
{
{
if
(
jbuf
.
size
()
>
maxsize
)
if
(
jbuf
.
size
()
>
maxsize
)
{
{
mywarn
<<
req
->
clientAddress
().
toString
()
<<
"
lost messages..."
<<
endl
;
mywarn
<<
req
->
clientAddress
().
toString
()
<<
"
(sendError): lost messages (maxsize="
<<
maxsize
<<
")"
<<
endl
;
return
;
return
;
}
}
...
@@ -1191,7 +1196,10 @@ void UWebSocketGate::UWebSocket::setSendPeriod ( const double& sec )
...
@@ -1191,7 +1196,10 @@ void UWebSocketGate::UWebSocket::setSendPeriod ( const double& sec )
void
UWebSocketGate
::
UWebSocket
::
setMaxSendCount
(
size_t
val
)
void
UWebSocketGate
::
UWebSocket
::
setMaxSendCount
(
size_t
val
)
{
{
if
(
val
>
0
)
if
(
val
>
0
)
{
maxsend
=
val
;
maxsend
=
val
;
maxsize
=
maxsend
*
Kbuf
;
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UWebSocketGate
::
UWebSocket
::
setMaxCmdCount
(
size_t
val
)
void
UWebSocketGate
::
UWebSocket
::
setMaxCmdCount
(
size_t
val
)
...
...
extensions/UWebSocketGate/UWebSocketGate.h
View file @
400cfbe2
...
@@ -169,7 +169,7 @@ namespace uniset
...
@@ -169,7 +169,7 @@ namespace uniset
- "get:id1,id2,name3,..." - получить текущее значение датчиков (разовое сообщение ShortSensorInfo)
- "get:id1,id2,name3,..." - получить текущее значение датчиков (разовое сообщение ShortSensorInfo)
Если длин
н
а команды превышает допустимое значение, то возвращается ошибка
Если длина команды превышает допустимое значение, то возвращается ошибка
\code
\code
{
{
"data": [
"data": [
...
@@ -177,6 +177,9 @@ namespace uniset
...
@@ -177,6 +177,9 @@ namespace uniset
]
]
}
}
\endcode
\endcode
\warning Под хранение сообщений для отправки выделяется Kbuf*maxSend. Kbuf в текущей реализации равен 10.
Т.е. если настроено maxSend=5000 сообщений, то буфер сможет максимально хранить 50000 сообщений.
*/
*/
class
UWebSocketGate
:
class
UWebSocketGate
:
public
UniSetObject
,
public
UniSetObject
,
...
@@ -252,8 +255,8 @@ namespace uniset
...
@@ -252,8 +255,8 @@ namespace uniset
double
wsHeartbeatTime_sec
=
{
3
.
0
};
double
wsHeartbeatTime_sec
=
{
3
.
0
};
double
wsSendTime_sec
=
{
0
.
5
};
double
wsSendTime_sec
=
{
0
.
5
};
size_t
wsMaxSend
=
{
2
00
};
size_t
wsMaxSend
=
{
50
00
};
size_t
wsMaxCmd
=
{
1
00
};
size_t
wsMaxCmd
=
{
2
00
};
static
Poco
::
JSON
::
Object
::
Ptr
to_json
(
const
uniset
::
SensorMessage
*
sm
,
const
std
::
string
&
err
);
static
Poco
::
JSON
::
Object
::
Ptr
to_json
(
const
uniset
::
SensorMessage
*
sm
,
const
std
::
string
&
err
);
static
Poco
::
JSON
::
Object
::
Ptr
error_to_json
(
const
std
::
string
&
err
);
static
Poco
::
JSON
::
Object
::
Ptr
error_to_json
(
const
std
::
string
&
err
);
...
@@ -320,8 +323,9 @@ namespace uniset
...
@@ -320,8 +323,9 @@ namespace uniset
ev
::
timer
iosend
;
ev
::
timer
iosend
;
double
send_sec
=
{
0
.
5
};
double
send_sec
=
{
0
.
5
};
size_t
maxsend
=
{
200
};
size_t
maxsend
=
{
5000
};
size_t
maxcmd
=
{
100
};
size_t
maxcmd
=
{
200
};
static
int
Kbuf
=
{
10
};
// коэффициент для буфера сообщений (maxsend умножается на Kbuf)
ev
::
timer
ioping
;
ev
::
timer
ioping
;
double
ping_sec
=
{
3
.
0
};
double
ping_sec
=
{
3
.
0
};
...
...
extensions/UWebSocketGate/start_fg.sh
View file @
400cfbe2
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
ulimit
-Sc
1000000
ulimit
-Sc
1000000
uniset2-start.sh
-f
./uniset2-wsgate
--confile
test.xml
--ws-name
UWebSocketGate1
--ws-log-add-levels
any
--ws-max-cmd
3
$*
uniset2-start.sh
-f
./uniset2-wsgate
--confile
test.xml
--ws-name
UWebSocketGate1
--ws-log-add-levels
crit,warn,level1
$*
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment