Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9197369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:03:37+00:00 2026-06-17T22:03:37+00:00

I connected successfully to onlinenic API using TCP client, but facing an error when

  • 0

I connected successfully to onlinenic API using TCP client, but facing an error when trying to login.

Below is my code (Username and password are demo as was provided by onlinenic)

    Imports System
    Imports System.Net.Sockets
    Imports System.Text
Imports System.Security.Cryptography
Imports System.IO
Imports System.Text.RegularExpressions
Imports System.Configuration
Imports System.Xml.Linq
Imports System.Xml

Partial Public Class _Default
    Inherits System.Web.UI.Page
    Private client As New TcpClient()
    Private stream As NetworkStream
    Private PortNo As Integer = 30009
    Private testIP As String = "218.5.81.149"
    Private testID As String = "135610"
    Private testPassword As String = "654123"
    Private Function Connect() As Boolean
        client.Connect(testIP, PortNo)
        stream = client.GetStream()
        Dim responseData As String = ""
        Dim data As [Byte]() = New [Byte](255) {}
        Dim bytes As Int32 = stream.Read(data, 0, data.Length)
        responseData = Encoding.ASCII.GetString(data, 0, bytes)
        Return responseData.Contains("Your Connection with API Server is Successful")
    End Function




    Private Function Login() As Boolean
        Dim HashedPass As String = CreateMd5Hash(testPassword)
        Dim guid__1 As Guid = Guid.NewGuid()
        Dim chksum As String = CreateMd5Hash(testID + HashedPass + guid__1.ToString() + "login")
        Dim sb As New StringBuilder()
        sb.Append("<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?>")
        sb.Append("<request>")
        sb.Append("<category>client</category>")
        sb.Append("<action>Login</action>")
        sb.Append("<params>")
        sb.Append("<param name=""clid"">" + testID + "</param>")
        sb.Append("</params>")
        sb.Append("<cltrid>" + guid__1.ToString() + "</cltrid>")
        sb.Append("<chksum>" + chksum + "</chksum>")
        sb.Append("</request>")
        Dim responseData As [String] = [String].Empty
        Dim data As [Byte]()
        data = System.Text.Encoding.ASCII.GetBytes(sb.ToString())
        stream.Write(data, 0, data.Length)
        Dim bytes As Int32 = stream.Read(data, 0, data.Length)
        responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
        bytes = stream.Read(data, 0, data.Length)
        responseData += System.Text.Encoding.ASCII.GetString(data, 0, bytes)
        Return responseData.Contains("Command completed successfully")
    End Function

when i try to connect using the above login() function I got the following error :

Object reference not set to an instance of an object.

Line 49:         Dim data As [Byte]()
Line 50:         data = System.Text.Encoding.ASCII.GetBytes(sb.ToString())
Line 51:         stream.Write(data, 0, data.Length)
Line 52:         Dim bytes As Int32 = stream.Read(data, 0, data.Length)
Line 53:         responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)

The error message am getting on this line : stream.Write(data, 0, data.Length)

System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=App_Web_4023pkvf StackTrace:
at _Default.Login() in D:\Documents and Settings\sa\My Documents\Visual Studio
2010\WebSites\onlinenic_vb1\Default.aspx.vb:line 51
at _Default.Button2_Click(Object sender, EventArgs e) in D:\Documents and Settings\sa\My Documents\Visual Studio
2010\WebSites\onlinenic_vb1\Default.aspx.vb:line 243
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:03:39+00:00Added an answer on June 17, 2026 at 10:03 pm

    You should try this :

     Dim HashedPass As String = CreateMd5Hash(testPassword)
            Dim guid__1 As Guid = Guid.NewGuid()
            Dim chksum As String = CreateMd5Hash(testID + HashedPass + guid__1.ToString() + "login")
            Dim sb As New StringBuilder()
            sb.Append("<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?>")
            sb.Append("<request>")
            sb.Append("<category>client</category>")
            sb.Append("<action>Login</action>")
            sb.Append("<params>")
            sb.Append("<param name=""clid"">" + testID + "</param>")
            sb.Append("</params>")
            sb.Append("<cltrid>" + guid__1.ToString() + "</cltrid>")
            sb.Append("<chksum>" + chksum + "</chksum>")
            sb.Append("</request>")
            Dim responseData As [String] = [String].Empty
            Dim data As [Byte]()
            data = System.Text.Encoding.ASCII.GetBytes(sb.ToString())
            stream.Write(data, 0, data.Length)
            Dim bytes As Int32 = stream.Read(data, 0, data.Length)
            responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
            bytes = stream.Read(data, 0, data.Length)
            responseData += System.Text.Encoding.ASCII.GetString(data, 0, bytes)
            Return responseData.Contains("Command completed successfully")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have connected with the database successfully by using wizard in server explorer. but
database get connected successfully....but... here is my code <?php $host = 'localhost'; $user =
Has anyone successfully connected to their MS Access db using Jasper Reports iReport? I
I am using MongoDB and FuelPHP. I successfully connected to MongoDB and can extract
We have successfully connected to the fusion table through our java application but we
I've successfully connected to a IBM DB2 database in SPSS using the connection wizard.
i have written the following code but it is giving parse error . here
I have successfully connected to my FTP using PHP and I can see all
I've successfully connected to XMPP server (from android XMPP client), and I can send
I successfully connected to my database when it was SQL Server 2008 R2. However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.