locked
Connection is not establishing with bank server RRS feed

  • Question

  • Hi,

    While connecting to the Bank server i am having problem of  connection i mean the connection is not establishing while sending a message to server.

    When is use to check the connection is true or false it shows false. Please check it and reply asap

    The code which i use is:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    using Trx.Messaging.Iso8583;
    using Trx.Messaging;
    using Trx.Communication.Channels.Sinks;
    using Trx.Communication.Channels.Sinks.Framing;
    using Trx.Coordination.TupleSpace;
    using Trx.Communication.Channels.Tcp;
    using Trx.Communication.Channels;
    using System.Net.Security;
    using System.Net.Sockets;

    namespace ISO8583Sample
    {
        public partial class Form1 : Form
        {
            private Stream stream;
            public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Load(object sender, EventArgs e)
            {

              

            }

            private void txt_Message_Click(object sender, EventArgs e)
            {
                System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient("###.###.#.###", 45510);
                SslStream sslstream = new SslStream(tcpClient.GetStream(), false);
                // sslstream.AuthenticateAsClient("###.###.#.###");
                // stream = sslstream;
                Stream s = tcpClient.GetStream();
                s.Close();
                tcpClient.Close();

                var message = new Iso8583Message(1200);



                // MessageId: 0200


                message.Fields.Add(002, "4584510200259251");
                message.Fields.Add(002, "4584510200259251");
                message.Fields.Add(003, "310000");
                message.Fields.Add(004, "000000000000");
                message.Fields.Add(007, "2014082310");
                message.Fields.Add(011, "003330");
                message.Fields.Add(012, "100044");
                message.Fields.Add(013, "0823");
                message.Fields.Add(014, "1802");
                message.Fields.Add(018, "6011");
                message.Fields.Add(022, "021");
                message.Fields.Add(032, "369421");
                message.Fields.Add(035, "4584510200259251=18021261366781000000");
                message.Fields.Add(037, "423500204678");
                message.Fields.Add(041, "NICB0018");
                message.Fields.Add(042, "NDC");
                message.Fields.Add(043, "MAJIVADE BRANCH          THANA        IN");
                message.Fields.Add(048, "YN");
                message.Fields.Add(049, "356");
                message.Fields.Add(102, "018330010001803");
                message.Fields.Add(108, "0180020 1");
                message.Fields.Add(116, "000000000000");


                var pipeline = new Pipeline();
                pipeline.Push(new ReconnectionSink());
                pipeline.Push(new NboFrameLengthSink(2) { IncludeHeaderLength = false, MaxFrameLength = 1024 });
                pipeline.Push(new MessageFormatterSink(new Iso8583MessageFormatter("Iso8583Bin1987.xml")));
                var ts = new TupleSpace<ReceiveDescriptor>();
                var client = new TcpClientChannel(pipeline, ts, new FieldsMessagesIdentifier(new[] { 11, 101 }))
                {
                    RemotePort = 45510,
                    RemoteInterface = "###.###.#.###",
                    //  Name = "Merchant"
                };

                client.Connect();

                if (client.IsConnected == true)
                {
                    SendRequestHandlerCtrl sndCtrl = client.SendExpectingResponse(message, 30000, false, null);
                    sndCtrl.WaitCompletion();
                    if (!sndCtrl.Successful)
                    {
                        Console.WriteLine("Cannot send.");
                        if (sndCtrl.Error != null)
                            Console.WriteLine(sndCtrl.Error);
                    }
                    sndCtrl.Request.WaitResponse();
                    if (sndCtrl.Request.IsExpired)
                        Console.WriteLine("Expired!");
                    else
                        Console.WriteLine("OK, we have a response!");
                }

            }
        }
    }


    Wednesday, August 27, 2014 5:25 AM