SMPPServer Failure processing data from 3 Clients

.NET library for SMPP protocol
Locked
olumosco
Posts: 4
Joined: Thu Jul 23, 2015 12:37 pm

SMPPServer Failure processing data from 3 Clients

Post by olumosco » Thu Jul 23, 2015 2:16 pm

Hello Alt,

We are in the process of evaluating this great component before making final purchase. One of the feature we are most interested in is SPEED of the Server. As such we did the test below by having 3 Clients connect to the Server and send 1,000 msgs each in Async mode and the Server saves them into the database.
We used SQL Server and Oracle as the Database, for both, not all msgs are saved successfully into the database. Out of the expected 3,000 msgs only 568 or less are saved in the database. It gives Access Violation error - {A first chance exception of type 'System.AccessViolationException' occurred in Oracle.DataAccess.dll}.
But if we only use One SMPP CLient to connect to the Server, ALL the messages are saved successfully in Oracle DB. In SQL Server, attimes 20 or more are missing.

Please is the problem with the database or with the component? Or the component cannot handle the high-throughput?
See the code below. We used the un-modified Demo CLient.

Code: Select all

Private Sub server_evClientSubmitSm(ByVal sender As Object, ByVal client As SmppServerClient, ByVal data As Inetlab.SMPP.PDU.SubmitSm)
	Dim payload() As Byte = data.Optional(OptionalTags.MessagePayload)
	Dim msgTXT As String
	If payload IsNot Nothing Then
		Dim messageText As String = client.GetMessageText(payload, data.DataCoding)
		msgTXT = messageText
		'   _log.Info(String.Format("Client {0}:{1} Received message Src:{2}, Dst:{3}, Text: {4}", client.RemoteIP, client.RemotePort, data.DestAddr, data.SourceAddr, messageText))
	Else
		msgTXT = data.MessageText
		'    _log.Info(String.Format("Client {0}:{1} Received message Src:{2}, Dst:{3}, Text: {4}", client.RemoteIP, client.RemotePort, data.DestAddr, data.SourceAddr, data.MessageText))
	End If

	Dim eror As String
	eror = sql.GW_InsertMessage(data.Response.MessageId, data.Sequence, msgTXT, data.DestAddr, client.SystemID, data.SourceAddr, "SMPP", 1, data.DataCoding, data.EsmClass)
	If eror <> "" Then _log.Info(String.Format("DB-ERROR {0}:{1} INSERT-ERROR:{2}", client.RemoteIP, client.RemotePort, eror))

	' Set unsuccess response status
	'data.Response.Status = CommandStatus.ESME_RSUBMITFAIL;
	'If data.RegisteredDelivery = 1 Then
	'    'Send Delivery Receipt when required
	'    client.DeliverAsync(SMS.ForDeliver().From(data.SourceAddr, data.SourceAddrTon, data.SourceAddrNpi).To(data.DestAddr, data.DestAddrTon, data.DestAddrNpi).Coding(data.DataCoding).Receipt(New Receipt With {.DoneDate = Date.Now, .State = MessageState.Delivered, .MessageId = data.Response.MessageId, .ErrorCode = "0", .SubmitDate = Date.Now, .Text = data.MessageText}))
	'End If
End Sub
		
		
Public Class SQLControl

    Public SQLConn As New SqlConnection With {.ConnectionString = "Server=MAINHOST\SQLEXPRESS;Database=smsgateway;User=sms;PWD=*****;"}
    Public SQLCmd As SqlCommand
    Public SQLDA As SqlDataAdapter
    Public SQLDataset As DataSet

    Public Function Connect2DB(ByRef sErr As String) As Boolean
        If SQLConn.State = ConnectionState.Open Then Return True
        Try
            SQLConn.Open()
            sErr = ""
            Return True
        Catch ex As Exception
            sErr = ex.Message
            Return False
        End Try
    End Function

    Public Function GW_InsertMessage(msgID As String, msgSEQ As UInteger, msgTEXT As String, mobileNO As String, userID As String, senderID As String, msgSource As String, msgParts As Integer, datacoding As Integer, esmclass As Integer) As String
        Dim er As String = ""
        Dim insSQL As String

        insSQL = "insert into outbox (message_id, sequence_no, message_text, mobile_no, submit_time, senderid, subscriber_id, message_source, sms_parts, datacoding, esmclass, message_status) values ( "
        insSQL = insSQL + "'" + msgID + "'"
        insSQL = insSQL + ",'" + msgSEQ.ToString + "'"
        insSQL = insSQL + ",'" + msgTEXT + "'"
        insSQL = insSQL + ",'" + mobileNO + "'"
        insSQL = insSQL + ",'" + System.DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss") + "'"
        insSQL = insSQL + ",'" + senderID + "'"
        insSQL = insSQL + ",'" + userID + "'"
        insSQL = insSQL + ",'" + msgSource + "'"
        insSQL = insSQL + ",'" + msgParts.ToString + "'"
        insSQL = insSQL + ",'" + datacoding.ToString + "'"
        insSQL = insSQL + ",'" + esmclass.ToString + "'"
        insSQL = insSQL + ",'" + "NEW" + "'"
        insSQL = insSQL + ")"

        If Connect2DB(er) Then
            Try
                SQLCmd = New SqlCommand(insSQL, SQLConn)
                SQLCmd.ExecuteNonQuery()
                Return ""
            Catch ex As Exception
                Return ex.Message
            End Try
        Else
            Return er
        End If

    End Function
End Class
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: SMPPServer Failure processing data from 3 Clients

Post by alt » Mon Jul 27, 2015 4:32 pm

Hello olumosco,

Usually database connection doesn't support multi-threading.

You can find solutions at http://stackoverflow.com/questions/2505 ... ing-in-net
Locked