Results 1 to 2 of 2
  1. #1
    Gratin's Avatar
    Join Date
    Apr 2013
    Gender
    male
    Posts
    182
    Reputation
    21
    Thanks
    501
    My Mood
    Inspired

    Keep getting connection reset trying to make a tcp proxy

    Hey guys so I'm just trying to make a tcp proxy to learn and for fun.

    I successfully accept the first bytes from the client but all i get is this byte array:

    60, 112, 111, 108, 105, 99, 121, 45, 102, 105, 108, 101, 45, 114, 101, 113, 117, 101, 115, 116, 47, 62, 0

    which translates to this utf8
    <policy-file-request/>

    And thats all i get whenever 059's or the new vanilla build tries to connect. However when i send this to the server, I get an instent connection reset.

    I'm kinda stuck on this step, any tips? Some code is attached for reference. I'm thinking maybe its because I'm not reading the socket properly?

    Proxy Accepting connection from client & reading packet

    Code:
    fun start(){
            val socketBuilder = aSocket(ActorSelectorManager(Dispatchers.IO)).tcp()
            val proxy = socketBuilder.bind(InetSocketAddress("localhost", 2050))
    
            runBlocking {
                while(true) {
                    val clientSocket: Socket = proxy.accept()
                    launch {
                        println("Connection accepted: ${clientSocket.remoteAddress}")
                        val clientInput = clientSocket.openReadChannel()
                        val clientPacket = clientInput.toByteArray()
                        if(clientPacket.isNotEmpty()){
                            println("Client packet received:  ${clientPacket.size} bytes")
                            for(b: Byte in clientPacket){
                                print("$b, ")
                            }
                        }
                    }
                }
            }
        }
    Attempting to forward what i got from the client to the server & seeing if i get a response (ends up only in an instant connection reset)

    The server IP that I'm connecting to is USWest (54.215.224.118) on port 2050
    Code:
    runBlocking {
            val serverSocket = aSocket(ActorSelectorManager(Dispatchers.IO)).tcp().connect(InetSocketAddress("54.215.224.118", 2050))
            val input = serverSocket.openReadChannel()
            val output = serverSocket.openWriteChannel()
            val policy = byteArrayOf(60, 112, 111, 108, 105, 99, 121, 45, 102, 105, 108, 101, 45, 114, 101, 113, 117, 101, 115, 116, 47, 62, 0)
    //        output.writeStringUtf8("<policy-file-request/>\n")
            output.writeFully(policy)
            output.flush()
            while (true){
                val serverPacket = input.toByteArray()
                if(serverPacket.size > 0){
                    for(c in serverPacket){
                        print("$c, ")
                    }
                }
            }
     

    Quote Originally Posted by RyanFalterJr View Post
    Vouch for Gratin, he went first, i gave him the items. Easy trader trustworthy

  2. #2
    Simple's Avatar
    Join Date
    Aug 2017
    Gender
    male
    Location
    NexusMart
    Posts
    170
    Reputation
    27
    Thanks
    25
    My Mood
    Fine
    massive IQ be like...
    Are you looking for Realm Items at the best price?


    Accepting PayPal!

    Selling Decas/ST's | Oryx3 Runs | Maxing | Dungeon Runs | Duping | And Much More!

    ST's/Decas - 0.25 to 0.15 | 8/8 - $8.00 , 6/8 - $6.00 | Duping Standard | IM for more Info!






    Maxing:


    8/8 Maxing : $8.00 6/8 Maxing : $6.00

    Deca and ST Shop:


    Decas : $0.25 Ea. - $0.15 ea. ST's : $0.25 Ea. - $0.15 ea.

Similar Threads

  1. [Help Request] keep getting timedout but on a certain connection
    By meanbluepanda in forum Alliance of Valiant Arms (AVA) Help
    Replies: 1
    Last Post: 07-29-2013, 03:28 PM
  2. [Help Request] I keep getting this error when I try to edit my allocated ram.
    By gainb in forum Minecraft Help
    Replies: 1
    Last Post: 07-28-2013, 12:59 AM
  3. Replies: 1
    Last Post: 12-27-2012, 11:13 PM
  4. [Solved] I keep getting [connection has expired]
    By zubni in forum CrossFire Help
    Replies: 4
    Last Post: 01-15-2012, 06:57 PM
  5. I keep getting this error when ever i try to compile the hacks i made
    By zackwpulaski in forum Combat Arms Coding Help & Discussion
    Replies: 8
    Last Post: 11-10-2010, 11:42 AM