use of javax.sip.message.Response in project load-balancer by RestComm.
the class BackToBackUserAgent method forwardResponse.
private void forwardResponse(ResponseEvent receivedResponse) throws SipException {
try {
ServerTransaction serverTransaction = (ServerTransaction) receivedResponse.getClientTransaction().getApplicationData();
Request stRequest = serverTransaction.getRequest();
Response newResponse = this.messageFactory.createResponse(receivedResponse.getResponse().getStatusCode(), stRequest);
ListeningPoint peerListeningPoint = sp.getListeningPoint(transport);
ContactHeader peerContactHeader = ((ListeningPointExt) peerListeningPoint).createContactHeader();
newResponse.setHeader(peerContactHeader);
serverTransaction.sendResponse(newResponse);
} catch (InvalidArgumentException e) {
throw new SipException("invalid response", e);
} catch (ParseException e) {
throw new SipException("invalid response", e);
}
}
use of javax.sip.message.Response in project load-balancer by RestComm.
the class HealthcheckTest method testMediaFailure.
@Test
public void testMediaFailure() throws Exception {
int okCounter = 0;
setUp();
for (int i = 0; i < 8; i++) {
shootist.sendInitialInvite();
Thread.sleep(5000);
}
for (Response res : shootist.responses) if (res.getStatusCode() == Response.OK)
okCounter++;
assertEquals(5, okCounter);
assertEquals(0, badServer.getTestSipListener().getDialogCount());
assertEquals(5, goodServer.getTestSipListener().getDialogCount());
}
use of javax.sip.message.Response in project load-balancer by RestComm.
the class MediaFailureTest method testMediaFailure.
@Test
public void testMediaFailure() throws Exception {
int serviceAnavaible = 0;
int okCounter = 0;
setUp();
for (int i = 0; i < 8; i++) {
shootist.sendInitialInvite();
Thread.sleep(5000);
if (i == 6) {
badServer.stop();
goodServer.stop();
Thread.sleep(5000);
badServer.start();
Thread.sleep(8000);
}
}
for (Response res : shootist.responses) {
if (res.getStatusCode() == Response.SERVICE_UNAVAILABLE)
serviceAnavaible++;
if (res.getStatusCode() == Response.OK)
okCounter++;
}
assertEquals(3, serviceAnavaible);
assertEquals(5, okCounter);
assertEquals(1, badServer.getTestSipListener().getDialogCount());
assertEquals(4, goodServer.getTestSipListener().getDialogCount());
}
use of javax.sip.message.Response in project load-balancer by RestComm.
the class RegexTest method testRegexAddAndRemove.
@Test
public void testRegexAddAndRemove() throws Exception {
int okCounter = 0;
setUp();
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest("http://127.0.0.1:2006/lbnoderegex?regex=(-)&ip=127.0.0.1&port=4060");
conversation.getResponse(request);
Thread.sleep(2000);
shootist.sendInitial("Kostya-test", "here.com", Request.INVITE, null, null, null);
Thread.sleep(5000);
shootist.sendInitial("Nosach-test", "here.com", Request.INVITE, null, null, null);
Thread.sleep(5000);
request = new GetMethodWebRequest("http://127.0.0.1:2006/lbnoderegex?regex=(-)");
conversation.getResponse(request);
Thread.sleep(2000);
shootist.sendInitial("Kostya-test", "here.com", Request.INVITE, null, null, null);
Thread.sleep(5000);
shootist.sendInitial("Nosach-test", "here.com", Request.INVITE, null, null, null);
Thread.sleep(5000);
for (Response res : shootist.responses) {
if (res.getStatusCode() == Response.OK)
okCounter++;
}
assertEquals(4, okCounter);
assertEquals(3, node0.getTestSipListener().getDialogCount());
assertEquals(1, node1.getTestSipListener().getDialogCount());
}
use of javax.sip.message.Response in project load-balancer by RestComm.
the class Response5xxTest method testSend503Response.
@Test
public void testSend503Response() throws Exception {
setUp();
boolean was503 = false;
shootist.sendInitialInvite();
Thread.sleep(1000);
for (Response res : shootist.responses) {
if (res.getStatusCode() != Response.SERVICE_UNAVAILABLE)
was503 = true;
}
assertTrue(was503);
}
Aggregations