1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-06-16 18:30:03 +08:00

#866 恢复使用8035端口和http协议

This commit is contained in:
duke 2023-07-09 23:10:12 +08:00
parent 81fe5bf6a6
commit da8f78e2d9
2 changed files with 36 additions and 28 deletions

View File

@ -20,45 +20,40 @@ import com.corundumstudio.socketio.annotation.SpringAnnotationScanner;
import com.cskefu.cc.exception.InstantMessagingExceptionListener;
import jakarta.annotation.PreDestroy;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.server.Ssl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import java.io.IOException;
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;
@org.springframework.context.annotation.Configuration
public class MessagingServerConfigure {
public class MessagingServerConfigure implements ApplicationContextAware {
@Value("${uk.im.server.host}")
private String host;
@Value("${uk.im.server.port}")
private Integer port;
@Value("${web.upload-path}")
private String path;
@Value("${server.ssl.key-store}")
private String keyStore;
//
// @Value("${server.ssl.key-store-type}")
// private String keyStoreType;
@Value("${server.ssl.key-store-password}")
private String keyStorepassword;
@Value("${uk.im.server.threads}")
private String threads;
private SocketIOServer server;
private ApplicationContext applicationContext;
@Bean(name = "webimport")
public Integer getWebIMPort() {
return port;
}
@Bean
public SocketIOServer socketIOServer() throws NoSuchAlgorithmException, IOException {
public SocketIOServer socketIOServer() {
Configuration config = new Configuration();
//解决对此重启服务时netty端口被占用问题
com.corundumstudio.socketio.SocketConfig tmpConfig = new com.corundumstudio.socketio.SocketConfig();
@ -83,10 +78,18 @@ public class MessagingServerConfigure {
config.getSocketConfig().setTcpNoDelay(true);
config.getSocketConfig().setTcpKeepAlive(true);
//设置https
InputStream keyStoreStream = this.getClass().getResourceAsStream("/" + keyStore.split(":")[1]); // 读取证书文件流
config.setKeyStore(keyStoreStream); // 设置证书文件
config.setKeyStorePassword(keyStorepassword); // 设置证书密码
ServerProperties serverProperties = applicationContext.getBean(ServerProperties.class);
Ssl ssl = serverProperties.getSsl();
if (ssl != null) {
String keyStore = ssl.getKeyStore();
String keyStorePassword = ssl.getKeyStorePassword();
if (StringUtils.isNotEmpty(keyStore) && StringUtils.isNotEmpty(keyStorePassword)) {
InputStream keyStoreStream = this.getClass().getResourceAsStream("/" + keyStore.trim().split(":")[1]);
config.setKeyStore(keyStoreStream);
config.setKeyStorePassword(keyStorePassword);
}
}
return server = new SocketIOServer(config);
}
@ -99,4 +102,9 @@ public class MessagingServerConfigure {
public void destory() {
server.stop();
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}

View File

@ -23,12 +23,12 @@ management.security.enabled=false
server.session-timeout=86400
server.threads.max=2000
server.connection.max=2000
server.port=8443
server.port=8035
server.context-path=/
# IM Server
uk.im.server.port=8036
uk.im.server.host=www.cskefu.com
uk.im.server.host=localhost
uk.im.server.threads=1000
spring.mvc.servlet.load-on-startup=1
@ -172,11 +172,11 @@ extras.auth.super-admin.pass=
extras.log.request=off
spring.jpa.properties.hibernate.allow_update_outside_transaction=true
##############################################
# ssl
##############################################
server.ssl.key-store=classpath:cskefu.jks
server.ssl.key-alias=cskefu
server.ssl.key-store-password=123456
server.http2.enabled=true
# server.ssl.key-store=classpath:cskefu.jks
# server.ssl.key-alias=cskefu
# server.ssl.key-store-password=123456
# server.http2.enabled=true