Broadsoft XSI event consumer on .NET

I’ve been developing a Windows application that consumes Broadsoft XSI events. Broadsoft has a “comprehensive range of VoIP Applications in a Single Platform” and XSI is a way to consume data produced by their platform, allowing integration of a modern switchboard service with other types of applications.

The Broadsoft XSI API is designed for the web. You can interact with their web service using a callback URL or an event channel. You use a callback URL in a web application and an event channel when the application you’re developing is not available over an URL. An event channel boils down to a streaming HTTP connection. This post is about what I learned developing the application using an event channel.

Broadsoft has a sandbox for application developers. There’s a simple procedure to request one and it is very well supported, both during setup and when you need maintenance, like a password reset. You can use this environment to check your code without possibly disrupting the live environment.

The Broadsoft API uses XML or JSON for data exchange. You’ll find yourself inspecting messages and I installed tooling which easens that task. I’ve been using JSON Viewer and XML Notepad 2007 on Windows to inspect data produced by the Broadsoft XSI API and I installed Fiddler2 to get an idea of what data is being transmitted. The application I developed uses log4net for logging and I used Log Expert for live logfile tracing. You should definitely install tools like those when you start developing.

XSI Events work on an event channel, which is essentially an HTTP connection that’s not closed. The – remote – HTTP server uses it to publish messages intended for the client that initiated the connection. I was not able to find too much examples of streaming HTTP in a Windows application, and this one pointed me into the right direction. The event channel is kept alive when there’s a heartbeat: a message once every 30 seconds, depending on the configuration in use by the Service Provider. I’m on the safe side with a 20 second interval. Be sure to start the heartbeat right after channel creation as you’ll find yourself dealing with channel termination messages in about half a minute after initially creating the channel. In case you’re wondering, yes – it’s in the documentation, but there were more questions about this subject. The remote server uses the event channel to publish events. An event is an XML document. Almost every event needs a confirmation message and the remote server will close the channel when the event is not responded to.

The application stopped every now and then due to an System.Net.Sockets.SocketException. It wasn’t obvious when those occurred – which made it hard to debug – until I stumbled upon this post. It appears the CLI enforces limits on the number of parallel connections to the same host. By default, you can create 2 parallel connections to the same host and you’ll find the SocketException as soon as you try to create the next connection. I finally used the configuration to make sure the number of parallel connections to a web application is set to a number close to 10 because the HTTP connection consumes 1 connection, the heartbeat consumes a connection every 20 seconds and you may be processing an event or two which need confirmation. I think you get the idea 😉

I found some errors every now and then while processing events. It appeared that my application received partial XML documents. These partial documents were not well-formed. It appeared that the remainder of the event was in the next transfer. An XSI event is serialized into an XML document, and I was able to process the event once I concatenated these transfers. One must keep the original order in mind, which should be obvious.

I hope this post will save you some time and frustrations. Let me know if you encountered something I did not cover here and I’ll be more than happy to add it.

11 thoughts on “Broadsoft XSI event consumer on .NET”

      1. Hi,
        I trying to do new call using event stream.
        1. create event channel
        2. Subscription
        3. send Event response to broadsoft
        4. New call (basic call)

        When start new call then immediately get response subscriptionTerminateevent.

        Can you help why Subcriotion terminate each time.

        can you sample code for calling XSI event & other code

  1. Its such as you read my mind! You seem to understand so much approximately this,
    such as you wrote the ebook in it or something.
    I feel that you could do with some percent to pressure
    the message house a bit, however other than that, this is
    magnificent blog. A great read. I’ll certainly be
    back.

  2. I’m doing this same thing in PHP. Can you tell me how to generate the channelSetId that is needed to pass into the original request?

    1. The content of the channelsetid does not really matter. Just generate something you will be albe to use later on, as you need it when you create subscriptions. I use something dynamic, but you can basically use something like my-phpapp-channelsetid

  3. Hi, In my case the event subscriptions are not working. When we put a subscription request, we get back a success response with a subscription id but that subscription is not found when searched back in the system. Also the http url never gets called by the subscription proving they haven’t been activated.
    Please help. Has it got something to do with the users access rights. What access rights are needed for getting subscription for target type user .

    1. Hi, Are you working with a HttpContact uri? I’ve been working with an eventchannel and I’m not sure if I can be of help. Are you working on the Broadsoft Sandbox?

  4. We are trying to integrate with Nextiva using XSI instead of OCI. Does anyone know what the XSI endpoind URL and port are for Nextiva? We have hit a wall on their side as most of their folks only seem to be familiar with OCI. Thank you.

Leave a Reply to admin Cancel reply

Your email address will not be published. Required fields are marked *