Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make number of web-socket-workers / decoders configurable #166

Merged
merged 1 commit into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class JSONConfiguration {
public static final String USERNAME_PARAMETER = "USERNAME";
public static final String PASSWORD_PARAMETER = "PASSWORD";
public static final String CONNECT_TIMEOUT_IN_MS_PARAMETER = "CONNECT_TIMEOUT_IN_MS";
public static final String WEBSOCKET_WORKER_COUNT = "WEBSOCKET_WORKER_COUNT";

private final HashMap<String, Object> parameters = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ of this software and associated documentation files (the "Software"), to deal
public class WebSocketListener implements Listener {
private static final Logger logger = LoggerFactory.getLogger(WebSocketListener.class);

private static final int DEFAULT_WEBSOCKET_WORKER_COUNT = 4;
private static final int TIMEOUT_IN_MILLIS = 10000;

private static final int OCPPJ_CP_MIN_PASSWORD_LENGTH = 16;
Expand Down Expand Up @@ -78,7 +79,10 @@ public WebSocketListener(ISessionFactory sessionFactory, Draft... drafts) {
@Override
public void open(String hostname, int port, ListenerEvents handler) {
server =
new WebSocketServer(new InetSocketAddress(hostname, port), drafts) {
new WebSocketServer(
new InetSocketAddress(hostname, port),
configuration.getParameter(JSONConfiguration.WEBSOCKET_WORKER_COUNT, DEFAULT_WEBSOCKET_WORKER_COUNT),
drafts) {
@Override
public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) {
logger.debug(
Expand Down