Hello everyone,
I'm trying to program a simple call control example using the java SDK.
The suscription to the conversation events works ok, but when I try to make a call using a CreateCallRequest I see the call created in the Purecloud app (that I have opened side by side to my app), but I only receive the event of the new call created, in state CONTACTING, and one minute later the DISCONNECTED.
In the SBC we have seen that no SIP request is generated.
Any ideas on what I'm missing?
Regards,
Blas.
This is my code
public class Main {
private static UserMe me = null;
private static UsersApi _usersApi;
public static void main(String[] args) {
try {
String accessToken = "dVMsCahrLkCvpV9ydZD08ucVFKTl0n4xkKodI8lJCwmTkmazcMxwsTjFJ2w33EJyzmwMwDFMbCEJ4bYLCMNqKw";
// Create ApiClient instance
ApiClient apiClient = ApiClient.Builder.standard()
.withAccessToken(accessToken)
.withBasePath("https://api.mypurecloud.ie")
.build();
// Use the ApiClient instance
Configuration.setDefaultApiClient(apiClient);
// Initialize API instances
_usersApi = new UsersApi();
// Get me
GetUsersMeRequest request = GetUsersMeRequest.builder()
.withExpand(Collections.singletonList("presence"))
.build();
me = _usersApi.getUsersMe(request);
Print("User logged: " + me.getName());
NotificationHandler notificationHandler = NotificationHandler.Builder.standard()
.withWebSocketListener(new PCWebSocketListener())
.withNotificationListener(new UserPresenceListener(me.getId()))
.withNotificationListener(new ChannelMetadataListener())
.withNotificationListener(new ConversationListener(me.getId()))
.withAutoConnect(true)
.build();
Print("New Call");
ConversationsApi apiInstance = new ConversationsApi();
CreateCallRequest body = new CreateCallRequest();
body.setPhoneNumber("911111111");
CreateCallResponse response = apiInstance.postConversationsCalls(body);
Print("response: " + response.toString());
} catch (ApiException ex) {
Print("[API ERROR] " + ex.getMessage());
Print("[API ERROR] " + ex.getRawBody());
ex.printStackTrace();
} catch (Exception ex) {
Print("[ERROR] " + ex.getMessage());
ex.printStackTrace();
}
}
private static void Print(String mensaje){
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime());
System.out.println(timeStamp + " - " + mensaje);
}
}
EVENTS RECEIVED
10:07:40 - User logged: XXXXXXX
10:07:40 - New Call
10:07:41 - response: class CreateCallResponse {
id: c8ca3b38-402d-49ea-ad04-c2631a10aad0
name: null
selfUri: /api/v2/conversations/calls/c8ca3b38-402d-49ea-ad04-c2631a10aad0
}
10:07:42 - ConversationListener event recived
10:07:42 - class ConversationNotification {
id: c8ca3b38-402d-49ea-ad04-c2631a10aad0
maxParticipants: null
participants: [class ConversationNotificationParticipants {
id: a5093e07-f775-4e05-88db-fffdb4d51461
connectedTime: null
endTime: null
userId: 934a81c1-21ca-4c81-abb5-1eb37c637a15
externalContactId: null
externalOrganizationId: null
name: null
queueId: null
groupId: null
purpose: user
consultParticipantId: null
address: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
wrapupRequired: false
wrapupExpected: false
wrapupPrompt: null
wrapupTimeoutMs: null
wrapup: null
monitoredParticipantId: null
attributes: {}
calls: [class ConversationNotificationCalls {
id: 4770ded1-7454-4dcf-ba0a-63ada036f827
state: CONTACTING
recording: false
recordingState: NONE
muted: false
confined: false
held: false
errorInfo: null
disconnectType: null
startHoldTime: null
direction: OUTBOUND
documentId: null
self: class ConversationNotificationSelf {
name: null
nameRaw:
addressNormalized: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
addressRaw: 592ff99b2b6a6b1cc4823617+generali.orgspan.com
addressDisplayable: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
additionalProperties: {}
}
other: class ConversationNotificationAddress {
name: Madrid, Spain
nameRaw:
addressNormalized: tel:+34911111111
addressRaw: tel:911111111
addressDisplayable: null
additionalProperties: {}
}
provider: Edge
scriptId: null
peerId: null
connectedTime: null
disconnectedTime: null
disconnectReasons: []
faxStatus: null
additionalProperties: {}
}]
callbacks: []
chats: []
cobrowsesessions: []
emails: []
screenshares: []
socialExpressions: []
videos: []
additionalProperties: {}
}]
recordingState: none
address: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
}
10:08:41 - ConversationListener event recived
10:08:41 - class ConversationNotification {
id: c8ca3b38-402d-49ea-ad04-c2631a10aad0
maxParticipants: null
participants: [class ConversationNotificationParticipants {
id: a5093e07-f775-4e05-88db-fffdb4d51461
connectedTime: null
endTime: Wed Jun 21 10:08:51 CEST 2017
userId: 934a81c1-21ca-4c81-abb5-1eb37c637a15
externalContactId: null
externalOrganizationId: null
name: null
queueId: null
groupId: null
purpose: user
consultParticipantId: null
address: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
wrapupRequired: false
wrapupExpected: false
wrapupPrompt: null
wrapupTimeoutMs: null
wrapup: null
monitoredParticipantId: null
attributes: {}
calls: [class ConversationNotificationCalls {
id: 4770ded1-7454-4dcf-ba0a-63ada036f827
state: DISCONNECTED
recording: false
recordingState: NONE
muted: false
confined: false
held: false
errorInfo: class ConversationNotificationErrorInfo {
status: null
code: error.ininedgecontrol.connection.timeout
message: Call Connection Timeout
messageWithParams: Call Connection Timeout
messageParams: {}
contextId: null
uri: null
additionalProperties: {}
}
disconnectType: ERROR
startHoldTime: null
direction: OUTBOUND
documentId: null
self: class ConversationNotificationSelf {
name: null
nameRaw:
addressNormalized: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
addressRaw: 592ff99b2b6a6b1cc4823617+generali.orgspan.com
addressDisplayable: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
additionalProperties: {}
}
other: class ConversationNotificationAddress {
name: Madrid, Spain
nameRaw:
addressNormalized: tel:+34911111111
addressRaw: tel:911111111
addressDisplayable: null
additionalProperties: {}
}
provider: Edge
scriptId: null
peerId: null
connectedTime: null
disconnectedTime: Wed Jun 21 10:08:51 CEST 2017
disconnectReasons: []
faxStatus: null
additionalProperties: {}
}]
callbacks: []
chats: []
cobrowsesessions: []
emails: []
screenshares: []
socialExpressions: []
videos: []
additionalProperties: {}
}]
recordingState: none
address: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
}
10:08:41 - ConversationListener event recived
10:08:41 - class ConversationNotification {
id: c8ca3b38-402d-49ea-ad04-c2631a10aad0
maxParticipants: null
participants: [class ConversationNotificationParticipants {
id: a5093e07-f775-4e05-88db-fffdb4d51461
connectedTime: null
endTime: Wed Jun 21 10:08:51 CEST 2017
userId: 934a81c1-21ca-4c81-abb5-1eb37c637a15
externalContactId: null
externalOrganizationId: null
name: null
queueId: null
groupId: null
purpose: user
consultParticipantId: null
address: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
wrapupRequired: false
wrapupExpected: false
wrapupPrompt: null
wrapupTimeoutMs: null
wrapup: null
monitoredParticipantId: null
attributes: {}
calls: [class ConversationNotificationCalls {
id: 4770ded1-7454-4dcf-ba0a-63ada036f827
state: DISCONNECTED
recording: false
recordingState: NONE
muted: false
confined: false
held: false
errorInfo: class ConversationNotificationErrorInfo {
status: null
code: error.ininedgecontrol.connection.timeout
message: Call Connection Timeout
messageWithParams: Call Connection Timeout
messageParams: {}
contextId: null
uri: null
additionalProperties: {}
}
disconnectType: ERROR
startHoldTime: null
direction: OUTBOUND
documentId: null
self: class ConversationNotificationSelf {
name: null
nameRaw:
addressNormalized: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
addressRaw: 592ff99b2b6a6b1cc4823617+generali.orgspan.com
addressDisplayable: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
additionalProperties: {}
}
other: class ConversationNotificationAddress {
name: Madrid, Spain
nameRaw:
addressNormalized: tel:+34911111111
addressRaw: tel:911111111
addressDisplayable: null
additionalProperties: {}
}
provider: Edge
scriptId: null
peerId: null
connectedTime: null
disconnectedTime: Wed Jun 21 10:08:51 CEST 2017
disconnectReasons: []
faxStatus: null
additionalProperties: {}
}]
callbacks: []
chats: []
cobrowsesessions: []
emails: []
screenshares: []
socialExpressions: []
videos: []
additionalProperties: {}
}]
recordingState: none
address: sip:592ff99b2b6a6b1cc4823617+generali.orgspan.com@localhost
}