use of org.springframework.web.socket.client.standard.StandardWebSocketClient in project spring-boot by spring-projects.
the class WebSocketMessagingAutoConfigurationTests method setup.
@Before
public void setup() {
List<Transport> transports = Arrays.asList(new WebSocketTransport(new StandardWebSocketClient(new WsWebSocketContainer())), new RestTemplateXhrTransport(new RestTemplate()));
this.sockJsClient = new SockJsClient(transports);
}
use of org.springframework.web.socket.client.standard.StandardWebSocketClient in project portal by ixinportal.
the class KeySegmentationTask method buildTask.
public static void buildTask(final WebSocketSession session, final WebSocketMessage<?> message) throws UnsupportedEncodingException, NoSuchAlgorithmException, URISyntaxException {
// header 获取云盾秘钥连接 // TODO: 2017/11/29
final WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
MobileSecretKeyConfigExample configExample = new MobileSecretKeyConfigExample();
MobileSecretKeyConfig keyConfig = accesskeyLiensConfigService.selectByConfig(configExample);
// keyConfig.getPasswordNumber()
headers.add("appId", keyConfig.getPasswordNumber());
headers.add("Content-Signature", Base64.encode(HMACSHA1.getHmacSHA1(/*keyConfig.getPasswordNumber(),keyConfig.getPassword()*/
"1", "123"), false));
final URI uri = new URI(/*keyConfig.getConnectAddress()*/
"ws://192.168.102.237:8080/km/webSocketServer");
Runnable task = new Runnable() {
@Override
public void run() {
WebSocketClient webSocketClient = new StandardWebSocketClient();
webSocketClient.doHandshake(new KeySegmentationWebSocketHandler(session, message), headers, uri);
}
};
threadPool.execute(task);
}
use of org.springframework.web.socket.client.standard.StandardWebSocketClient in project elastest-torm by elastest.
the class StompTestUtils method connectToRabbitMQ.
public static StompSession connectToRabbitMQ(int serverPort) throws InterruptedException, ExecutionException, TimeoutException {
WebSocketContainer cont = ContainerProvider.getWebSocketContainer();
cont.setDefaultMaxTextMessageBufferSize(65500);
WebSocketClient webSocketClient = new StandardWebSocketClient(cont);
WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);
stompClient.setMessageConverter(new StringMessageConverter());
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.initialize();
// for heartbeats
stompClient.setTaskScheduler(taskScheduler);
stompClient.setDefaultHeartbeat(new long[] { 10000, 10000 });
String url = "ws://localhost:" + serverPort + "/rabbitMq";
StompSessionHandler sessionHandler = new LogConnectedSessionHandler();
final int MAX_RETRIES = 5;
int retry = 0;
while (true) {
try {
StompSession stompSession = stompClient.connect(url, sessionHandler).get(10, TimeUnit.SECONDS);
log.info("Test connected to RabbitMQ in URL '{}'", url);
return stompSession;
} catch (Exception e) {
if (retry < MAX_RETRIES) {
retry++;
log.warn("Exception trying to connect to RabbitMQ: {}:{}", e.getClass().getName(), e.getMessage());
log.info("Retrying {}/{} in 5 second", retry, MAX_RETRIES);
Thread.sleep(5000);
} else {
throw e;
}
}
}
}
use of org.springframework.web.socket.client.standard.StandardWebSocketClient in project spring-framework by spring-projects.
the class WebSocketStompClientIntegrationTests method setUp.
@BeforeEach
void setUp(TestInfo testInfo) throws Exception {
logger.debug("Setting up before '" + testInfo.getTestMethod().get().getName() + "'");
this.wac = new AnnotationConfigWebApplicationContext();
this.wac.register(TestConfig.class);
this.wac.refresh();
this.server = new TomcatWebSocketTestServer();
this.server.setup();
this.server.deployConfig(this.wac);
this.server.start();
WebSocketClient webSocketClient = new StandardWebSocketClient();
this.stompClient = new WebSocketStompClient(webSocketClient);
this.stompClient.setMessageConverter(new StringMessageConverter());
}
use of org.springframework.web.socket.client.standard.StandardWebSocketClient in project spring-boot by spring-projects.
the class WebSocketMessagingAutoConfigurationTests method setup.
@BeforeEach
void setup() {
List<Transport> transports = Arrays.asList(new WebSocketTransport(new StandardWebSocketClient(new WsWebSocketContainer())), new RestTemplateXhrTransport(new RestTemplate()));
this.sockJsClient = new SockJsClient(transports);
}
Aggregations