MapObject soft DC

Newbie Spellweaver
Joined
Dec 15, 2014
Messages
39
Reaction score
1
Does anyone knows what is causing the soft DC (back to login screen with Unable to connect message) when there are many drops on the ground? I have set my runningOID to 30k/500k etc but it still crashes whenever they are a lot of drops. I know for sure it is not lag that is causing this issue. It has something to do with drops because when I disable drops from mobs, it doesn't crash me.

This is my addMapObject in MapleMap (TiredStory):
Code:
public void addMapObject(MapleMapObject mapobject) {        objectlock.writeLock().lock();
        try {
            mapobject.setObjectId(runningOid);
            this.mapobjects.put(Integer.valueOf(runningOid), mapobject);
            incrementRunningOid();
        } finally {
            objectlock.writeLock().unlock();
        }
    }

Any help would be appreciated, thanks.
 
Code:
package net.mina;

import client.MapleClient;
import net.MaplePacket;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
import tools.MapleAESOFB;


public class MaplePacketEncoder implements ProtocolEncoder {


@Override
	public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
		MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
		if (client != null) {
			MapleAESOFB send_crypto = client.getSendCrypto();
			byte[] received_message = ((MaplePacket) message).getBytes().clone(); // Makes a copy so the original message is not modified.
			byte[] write = new byte[received_message.length + 4];
			synchronized (send_crypto) {
                            byte[] header = send_crypto.getPacketHeader(received_message.length);
				MapleCustomEncryption.encryptData(received_message);
				send_crypto.crypt(received_message);
				System.arraycopy(header, 0, write, 0, 4);
				System.arraycopy(received_message, 0, write, 4, received_message.length);
				out.write(IoBuffer.wrap(write));
			}
		} else {
			out.write(IoBuffer.wrap(((MaplePacket) message).getBytes()));
		}
	}


    public void dispose(IoSession session) throws Exception {
    }
}
 
Upvote 0
Followed the guide and converted my encode according to yours @Shmoconut

This is my current MapleEncoder:
Code:
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {            try {
         final MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
              final  byte[] input = ((MaplePacket) message).getBytes();
        if (client != null) {
                    final Lock mutex = client.getLock();
                    MapleAESOFB send_crypto = client.getSendCrypto();
                 final   byte[] write = new byte[input.length];
                 System.arraycopy(input, 0, write, 0, input.length);
                    final    byte[] ret = new byte[write.length + 4];
        MapleCustomEncryption.encryptData(write);
                    mutex.lock();
                    try {
                        final    byte[] header = send_crypto.getPacketHeader(input.length);
                send_crypto.crypt(write);
                System.arraycopy(header, 0, ret, 0, 4);
                System.arraycopy(write, 0, ret, 4, write.length);
                                ByteBuffer out_buffer = ByteBuffer.wrap(ret);
                session.write(out_buffer);
            } finally {
                        mutex.unlock();
                    }
        } else {
            out.write(ByteBuffer.wrap(input));
                }
            }    catch (Exception e) {
        throw new RuntimeException("ENCRYPTION EXCEPTION: ", e);
    }
}

Now I'm receiving firewall error. Any help?
 
Upvote 0
Hey dude,
There is likely nothing wrong with your encoder. A firewall error means
1. the client couldn't connect to the login server
2. the client connected to the login server but never received the hello packet

Your encoder does write a hello packet, and for what it's worth, I can use your encode() method and get in game. I'd assume your problem isn't related to encoder changes.
 
Upvote 0
Hi @Shmoconut

Can you open the client using TiredStory's source? (MapleBlade based)
Code:
[COLOR=#666666]public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {[/COLOR]        MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
        if (client != null) {
            MapleAESOFB send_crypto = client.getSendCrypto();
            byte[] received_message = ((MaplePacket) message).getBytes().clone(); // Makes a copy so the original message is not modified.
            byte[] write = new byte[received_message.length + 4];
            synchronized (send_crypto) {
                            byte[] header = send_crypto.getPacketHeader(received_message.length);
                MapleCustomEncryption.encryptData(received_message);
                send_crypto.crypt(received_message);
                System.arraycopy(header, 0, write, 0, 4);
                System.arraycopy(received_message, 0, write, 4, received_message.length);
                out.write(IoBuffer.wrap(write));
            }
        } else {
            out.write(IoBuffer.wrap(((MaplePacket) message).getBytes()));
        }
    }

    public void dispose(IoSession session) throws Exception {
    }
}
^ The original works but this doesn't:

Code:
[COLOR=#666666]public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {            try {[/COLOR][COLOR=#666666]  
       final MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);[/COLOR]              final  byte[] input = ((MaplePacket) message).getBytes();
        if (client != null) {
                    final Lock mutex = client.getLock();
                    MapleAESOFB send_crypto = client.getSendCrypto();
                 final   byte[] write = new byte[input.length];
                 System.arraycopy(input, 0, write, 0, input.length);
                    final    byte[] ret = new byte[write.length + 4];
        MapleCustomEncryption.encryptData(write);
                    mutex.lock();
                    try {
                        final    byte[] header = send_crypto.getPacketHeader(input.length);
                send_crypto.crypt(write);
                System.arraycopy(header, 0, ret, 0, 4);
                System.arraycopy(write, 0, ret, 4, write.length);
                                ByteBuffer out_buffer = ByteBuffer.wrap(ret);
                session.write(out_buffer);
            } finally {
                        mutex.unlock();
                    }
        } else {
            out.write(ByteBuffer.wrap(input));
                }
            }    catch (Exception e) {
        throw new RuntimeException("ENCRYPTION EXCEPTION: ", e);
    }
}

Is there anything that I might have missed while converting?
 
Upvote 0
@Baymax The only difference I see is:

Code:
final    byte[] header = send_crypto.getPacketHeader(input.length);

would need to be write.length. However, that shouldn't be the cause of your firewall because it never reaches that far (or shouldn't) until it's sent the handshake which is under the } else { portion. You're free to try that though and see if that's the cause. Otherwise, if the original encode works and is at least synchronized, just change the out.write line to session.write instead and use that if it works.
 
Upvote 0
IoBuffer is a MINA 2.x thing, and my fix was only tested with 1.x.

You need to replace session.write(ByteBuffer.wrap(ret)) with session.write(IoBuffer.wrap(ret));

Alternatively, you could try replacing the:
out.write(IoBuffer.wrap(write));

with:
out.write(IoBuffer.wrap(write));
out.flush();

I am not sure if it works because I haven't dug into MINA 2.x code, and they changed quite a few things around there. It would work with 1.x. If it works with 2.x, the flush is probably the better solution since it's forward compatible.

The rest of your encoder looks fine, so you only need to change or add 1 line to the original.
 
Upvote 0
I've managed to get to the login screen by changing
Code:
ByteBuffer out_buffer = ByteBuffer.wrap(ret); to IoBuffer out_buffer = IoBuffer.wrap(ret);

However, when I tried logging in, it disconnects me with this error:
gRbWzaY - MapObject soft DC - RaGEZONE Forums
 
Upvote 0
Despite adding out.flush(); to the original,
Code:
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
        MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
        if (client != null) {
            MapleAESOFB send_crypto = client.getSendCrypto();
            byte[] received_message = ((MaplePacket) message).getBytes().clone(); // Makes a copy so the original message is not modified.
            byte[] write = new byte[received_message.length + 4];
            synchronized (send_crypto) {
                            byte[] header = send_crypto.getPacketHeader(received_message.length);
                MapleCustomEncryption.encryptData(received_message);
                send_crypto.crypt(received_message);
                System.arraycopy(header, 0, write, 0, 4);
                System.arraycopy(received_message, 0, write, 4, received_message.length);
                out.write(IoBuffer.wrap(write));
                                out.flush();
            }
        } else {
            out.write(IoBuffer.wrap(((MaplePacket) message).getBytes()));
        }
    }

and using the lock method,
Code:
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {            try {
         final MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
              final  byte[] input = ((MaplePacket) message).getBytes();
        if (client != null) {
                    final Lock mutex = client.getLock();
                    MapleAESOFB send_crypto = client.getSendCrypto();
                 final   byte[] write = new byte[input.length];
                 System.arraycopy(input, 0, write, 0, input.length);
                    final    byte[] ret = new byte[write.length + 4];
                    send_crypto.crypt(write);
                    mutex.lock();
                    try {
                        final    byte[] header = send_crypto.getPacketHeader(input.length);
                send_crypto.crypt(write);
                System.arraycopy(header, 0, ret, 0, 4);
                System.arraycopy(write, 0, ret, 4, write.length);
                                IoBuffer out_buffer = IoBuffer.wrap(ret);
                session.write(out_buffer);
            } finally {
                        mutex.unlock();
                    }
        } else {
            out.write(IoBuffer.wrap(input));
                }
            }    catch (Exception e) {
        throw new RuntimeException("ENCRYPTION EXCEPTION: ", e);
    }
}


I still crash to Login screen when there are many drops. (Crash when drops disappear)
 
Upvote 0
Back