"Software caused connection abort" . Something wrong with your software. Java or your PC or something else i don't know.
Edit- You using OStava? NVM.
|
This is the error that is being printed out to the console:
Line 70 is this:Code:java.net.SocketException: Software caused connection abort: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(Unknown Source) at java.net.SocketOutputStream.write(Unknown Source) at com.runescape.revised.net.login.Login562.<init>(Login562.java:70) at com.runescape.revised.net.io.Login.run(Login.java:86) at java.lang.Thread.run(Unknown Source)
I'm completely lost as to how it's not able to write out the update keys to the client. Am I missing something here? Thanks in advance.Code:this.getOutputStream().write(Constants.UPDATE_KEYS[i]);
"Software caused connection abort" . Something wrong with your software. Java or your PC or something else i don't know.
Edit- You using OStava? NVM.
If that is the case that some software is causing problems, I'm starting to wonder what software it is. It's odd because when it writes out anything else (using an OutputStream), it won't come up for whatever's being written. No, I am not using OStava.
EDIT #1: I've read that this error deals with a Socket connection coming to a close, either locally or server-sided or client-sided. I'm unsure as to why the Socket would close on me. Any ideas?
Bump.
Here is the full login code:
When I use the AsynchronousSocketChannel rather than a regular Socket, I get the following:Code:package com.runescape.revised.net.login; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.nio.channels.AsynchronousSocketChannel; import com.runescape.Constants; import com.runescape.Main; import com.runescape.revised.actor.entity.AbstractEntity; import com.runescape.revised.actor.entity.player.GamePlayer; import com.runescape.revised.engine.impl.GameEngine; import com.runescape.revised.logic.encryption.Cryption; import com.runescape.revised.net.io.IOPacketBuffer; import com.runescape.revised.net.packets.codec.login.LoginStage; import com.runescape.revised.net.packets.codec.login.RevisionType; import com.runescape.revised.util.Text; public class Login562 { private IOPacketBuffer outStream, inStream; private InputStream inputStream; private OutputStream outputStream; private Cryption inStreamDecryption, outStreamDecryption; private LoginStage loginStage = LoginStage.FIRST; public Login562(final IOPacketBuffer outStream, final IOPacketBuffer inStream, final Socket socket, final AsynchronousSocketChannel clientSocket) { this.setOutStream(outStream); this.setInStream(inStream); // this.setInputStream(Channels.newInputStream(clientSocket)); // this.setOutputStream(Channels.newOutputStream(clientSocket)); try { this.setInputStream(socket.getInputStream()); this.setOutputStream(socket.getOutputStream()); } catch (final IOException ioe) { ioe.printStackTrace(); } final long clientSessionKey = 0, serverSessionKey = ((long) (Math.random() * 99999999D) << 32) + (long) (Math.random() * 99999999D); if (this.getLoginStage() == LoginStage.FIRST) { System.out.println("First Call: " + Main.getMain().getRevisionType().getRevisionID()); this.setLoginStage(LoginStage.FOURTH); final byte opcodeUpdate = (byte) this.getInStream().readUnsignedByte(); if (opcodeUpdate == 15) { System.out.println("Opcode is 15!"); this.setLoginStage(LoginStage.SECOND); } this.getOutStream().writeByte((byte) 0); this.getOutStream().writeQWord(0); this.flushOutStream(); this.getInStream().setCurrentOffset(0); } if (this.getLoginStage() == LoginStage.SECOND) { System.out.println("Second stage."); @SuppressWarnings("unused") final short clientRevision = (short) this.getInStream().readUnsignedWord(); try { this.getOutputStream().write(0); this.setLoginStage(LoginStage.THIRD); } catch (final IOException ioe) { ioe.printStackTrace(); } } if (this.getLoginStage() == LoginStage.THIRD) { System.out.println("Third stage."); Main.getMain().setRevisionType(RevisionType.FIVE_SIXTY_TWO); System.out.println("Second Call: " + Main.getMain().getRevisionType().getRevisionID()); for (int i = 0; i < Constants.UPDATE_KEYS.length; i++) { try { this.getOutputStream().write(Constants.UPDATE_KEYS[i]); } catch (final IOException ioe) { ioe.printStackTrace(); } } // this.flushOutStream(); } if (this.getLoginStage() == LoginStage.FOURTH) { System.out.println("Fourth stage."); this.flushOutStream(); this.fillInStream(2); System.out.println("Sending login type."); final int loginType = this.getInStream().readUnsignedByte(); if ((loginType != 16) && (loginType != 18)) { System.out.println("Login type is not 16 and 18 - " + loginType); return; } this.getInStream().readSkip(2); System.out.println("Sending revision."); @SuppressWarnings("unused") final short revision = (short) this.getInStream().readDWord(); this.getInStream().readSkip(30); this.getInStream().readString(); this.getInStream().readSkip(143); final long username = this.getInStream().readQWord(); final String name = Text.fixName(Text.longToString(username)).trim(); System.out.println("Name: " + name); final String password = this.getInStream().readString(); System.out.println("Password: " + password); System.out.println("Printed out username, user id, and password."); final int[] sessionKey = new int[4]; sessionKey[0] = (int) (clientSessionKey >> 32); sessionKey[1] = (int) clientSessionKey; sessionKey[2] = (int) (serverSessionKey >> 32); sessionKey[3] = (int) serverSessionKey; for (int i = 0; i < 4; i++) { Integer.toHexString(sessionKey[i]); } this.setInStreamDecryption(new Cryption(sessionKey)); for (byte i = 0; i < 4; i++) { sessionKey[i] += 50; } for (byte i = 0; i < 4; i++) { Integer.toHexString(sessionKey[i]); } this.setOutStreamDecryption(new Cryption(sessionKey)); this.getOutStream().setPacketEncryption(this.getOutStreamDecryption()); AbstractEntity player = null; try { player = new GamePlayer(name, null); } catch (final Exception e) { e.printStackTrace(); } try { System.out.println("Sending return code of 2."); this.getOutputStream().write(2); // return code if (player.getName().equals("Josh") || player.getName().equals("Rodriges")) { System.out.println("Sending player rights of 2 for " + player.getName()); this.getOutputStream().write(2); // rights } else { this.getOutputStream().write(0); // rights } this.getOutStream().writeByte((byte) 0); System.out.println("Sending login bytes."); this.getOutputStream().write((byte) 0); this.getOutputStream().write((byte) 0); this.getOutputStream().write((byte) 0); this.getOutputStream().write((byte) 0); this.getOutputStream().write((byte) 0); this.getOutStream().writeWord(1); // slot (playerID - same thing?) this.getOutputStream().write((byte) 1); this.getOutputStream().write((byte) 1); // members this.flushOutStream(); } catch (final IOException ioe) { ioe.printStackTrace(); } System.out.println("Sending map region packet."); this.getOutStream().createFrameVarSizeWord(76); this.getOutStream().writeWordBigEndianA(player.getLocation().getRegionX()); this.getOutStream().writeWord(player.getLocation().getY()); this.getOutStream().writeByte((byte) 0); this.getOutStream().writeByteA(0); boolean forceRegion = (((player.getLocation().getRegionX() / 8) == 48) || ((player.getLocation().getRegionX() / 8) == 49)) && ((player.getLocation().getRegionY() / 8) == 48); if (((player.getLocation().getRegionX() / 8) == 48) && ((player.getLocation().getRegionY() / 8) == 148)) { forceRegion = true; } for (int xCalc = (player.getLocation().getRegionX() - 6) / 8; xCalc <= ((player.getLocation().getRegionX() + 6) / 8); xCalc++) { for (int yCalc = (player.getLocation().getRegionY() - 6) / 8; yCalc <= ((player.getLocation().getRegionY() + 6) / 8); yCalc++) { final int region = yCalc + (xCalc << 8); final int[] mapData = Main.getMain().getMapData().getRegionData(region); if (forceRegion && ((yCalc == 49) || (yCalc == 149) || (yCalc == 147) || (xCalc == 50) || ((xCalc == 49) && (yCalc == 47)))) { this.getOutStream().writeDWord(-1); this.getOutStream().writeDWord(-1); this.getOutStream().writeDWord(-1); this.getOutStream().writeDWord(-1); } else { this.getOutStream().writeDWord(mapData[0]); this.getOutStream().writeDWord(mapData[1]); this.getOutStream().writeDWord(mapData[2]); this.getOutStream().writeDWord(mapData[3]); } } } this.getOutStream().writeByteA(player.getLocation().getZ()); this.getOutStream().writeWord(player.getLocation().getX()); this.getOutStream().writeWord(player.getLocation().getRegionY()); this.getOutStream().endFrameVarSizeWord(); this.getOutStream().createFrame(50); this.getOutStream().writeWordA(548); this.getOutStream().writeWord(0); this.getOutStream().writeByteS(0); this.getOutStream().createFrame(50); this.getOutStream().writeWordA(549); this.getOutStream().writeWord(0); this.getOutStream().writeByteS(0); this.flushOutStream(); new GameEngine((GamePlayer) player); } } public void flushOutStream() { if (this.getOutStream() == null) { System.out.println("Outstream is null."); return; } if (this.getOutStream().getCurrentOffset() == 0) { System.out.println("Current offset is 0."); return; } try { this.getOutputStream().write(this.getOutStream().getBuffer(), 0, this.getOutStream().getCurrentOffset()); } catch (final IOException ioe) { ioe.printStackTrace(); } this.getOutStream().setCurrentOffset(0); } public void fillInStream(final int forceRead) { if (this.getInStream() == null) { System.out.println("InStream is null."); return; } this.getInStream().setCurrentOffset(0); try { this.getInputStream().read(this.getInStream().getBuffer(), 0, forceRead); } catch (final IOException ioe) { ioe.printStackTrace(); } } public void setOutStream(final IOPacketBuffer outStream) { this.outStream = outStream; } public IOPacketBuffer getOutStream() { return this.outStream; } public void setInStream(final IOPacketBuffer inStream) { this.inStream = inStream; } public IOPacketBuffer getInStream() { return this.inStream; } public void setInputStream(final InputStream inputStream) { this.inputStream = inputStream; } public InputStream getInputStream() { return this.inputStream; } public void setOutputStream(final OutputStream outputStream) { this.outputStream = outputStream; } public OutputStream getOutputStream() { return this.outputStream; } public void setInStreamDecryption(final Cryption inStreamDecryption) { this.inStreamDecryption = inStreamDecryption; } public Cryption getInStreamDecryption() { return this.inStreamDecryption; } public void setOutStreamDecryption(final Cryption outStreamDecryption) { this.outStreamDecryption = outStreamDecryption; } public Cryption getOutStreamDecryption() { return this.outStreamDecryption; } public void setLoginStage(final LoginStage loginStage) { this.loginStage = loginStage; } public LoginStage getLoginStage() { return this.loginStage; } }
Code:java.io.IOException: java.io.IOException: An established connection was aborted by the software in your host machine at java.nio.channels.Channels$3.write(Unknown Source) at java.io.OutputStream.write(Unknown Source) at java.nio.channels.Channels$3.write(Unknown Source) at com.runescape.revised.net.login.Login562.<init>(Login562.java:71) at com.runescape.revised.net.io.Login.run(Login.java:85) at java.lang.Thread.run(Unknown Source)
Bump.
I'm guessing another program is trying to connect?
I honestly don't see any other programs trying to connect. Other servers I've tried can log into the same client but my server is the only one that cannot which I find really odd seeing how I can't find anything in my server that would cause this error.
Here's a partial bit of my server - Login only:
IO Class (I decided to go from IO to NIO 2.0):
Login Class:Code:/** * Class constructor. */ public IO() { final Timer timer = new Timer(); try { final AsynchronousChannelGroup serverGroup = AsynchronousChannelGroup.withThreadPool(Executors.newSingleThreadExecutor()); this.setAsynchronousServerSocket(AsynchronousServerSocketChannel.open(serverGroup).bind(new InetSocketAddress(Constants.PORT))); System.out.println("IO started in " + timer.toString()); while (this.isRunning()) { final Future<AsynchronousSocketChannel> serverFuture = this.getAsynchronousServerSocket().accept(); try { this.setAsynchronousClientSocket(serverFuture.get()); this.getAsynchronousClientSocket().setOption(StandardSocketOptions.SO_KEEPALIVE, Boolean.TRUE); this.getAsynchronousClientSocket().setOption(StandardSocketOptions.TCP_NODELAY, Boolean.TRUE); } catch (InterruptedException | ExecutionException ee) { ee.printStackTrace(); } this.setClientThread(new Login(this.getAsynchronousClientSocket())); } this.setRunning(false); this.getAsynchronousServerSocket().close(); this.getAsynchronousClientSocket().close(); } catch (final SocketException se) { se.printStackTrace(); this.setRunning(false); } catch (final IOException ioe) { ioe.printStackTrace(); this.setRunning(false); } } }
Login562 Class:Code:/* * (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { this.setOutStream(new IOPacketBuffer(new byte[Constants.BUFFER_SIZE])); this.getOutStream().setCurrentOffset(0); this.setInStream(new IOPacketBuffer(new byte[Constants.BUFFER_SIZE])); this.getInStream().setCurrentOffset(0); this.fillInStream(2); /** * Switch between each revision. */ switch (Main.getMain().getRevisionType()) { case THREE_ONE_SEVEN: new Login317(this.getOutStream(), this.getInStream(), this.getClientSocket()); break; case FOUR_SEVEN_FOUR: new Login474(); break; case FIVE_OH_EIGHT: new Login508(); break; case FIVE_SIXTY_TWO: new Login562(this.getOutStream(), this.getInStream(), this.getClientSocket()); break; default: System.out.println("Revision not supported!"); } } }
I switched from Windows 7 to Ubuntu 12.04. With Windows 7, I get the following:Code:public Login562(final IOPacketBuffer outStream, final IOPacketBuffer inStream, final AsynchronousSocketChannel clientSocket) { this.setOutStream(outStream); this.setInStream(inStream); this.setInputStream(Channels.newInputStream(clientSocket)); this.setOutputStream(Channels.newOutputStream(clientSocket)); final long clientSessionKey = 0, serverSessionKey = ((long) (Math.random() * 99999999D) << 32) + (long) (Math.random() * 99999999D); if (this.getLoginStage() == LoginStage.FIRST) { System.out.println("First Call: " + Main.getMain().getRevisionType().getRevisionID()); this.setLoginStage(LoginStage.FOURTH); final byte opcodeUpdate = (byte) this.getInStream().readUnsignedByte(); if (opcodeUpdate == 15) { System.out.println("Opcode is 15!"); this.setLoginStage(LoginStage.SECOND); } this.getOutStream().writeByte((byte) 0); this.getOutStream().writeQWord(0); this.flushOutStream(); this.getInStream().setCurrentOffset(0); } if (this.getLoginStage() == LoginStage.SECOND) { System.out.println("Second stage."); @SuppressWarnings("unused") final short clientRevision = (short) this.getInStream().readUnsignedWord(); try { this.getOutputStream().write(0); this.setLoginStage(LoginStage.THIRD); } catch (final IOException ioe) { ioe.printStackTrace(); } } if (this.getLoginStage() == LoginStage.THIRD) { System.out.println("Third stage."); Main.getMain().setRevisionType(RevisionType.FIVE_SIXTY_TWO); System.out.println("Second Call: " + Main.getMain().getRevisionType().getRevisionID()); for (int i = 0; i < Constants.UPDATE_KEYS.length; i++) { try { this.getOutputStream().write(Constants.UPDATE_KEYS[i]); } catch (final IOException ioe) { ioe.printStackTrace(); } } // this.flushOutStream(); } if (this.getLoginStage() == LoginStage.FOURTH) { System.out.println("Fourth stage."); this.flushOutStream(); this.fillInStream(2); System.out.println("Sending login type."); final int loginType = this.getInStream().readUnsignedByte(); if ((loginType != 16) && (loginType != 18)) { System.out.println("Login type is not 16 and 18 - " + loginType); return; } this.getInStream().readSkip(2); System.out.println("Sending revision."); @SuppressWarnings("unused") final short revision = (short) this.getInStream().readDWord(); this.getInStream().readSkip(30); this.getInStream().readString(); this.getInStream().readSkip(143); final long username = this.getInStream().readQWord(); final String name = Text.fixName(Text.longToString(username)).trim(); System.out.println("Name: " + name); final String password = this.getInStream().readString(); System.out.println("Password: " + password); System.out.println("Printed out username, user id, and password."); final int[] sessionKey = new int[4]; sessionKey[0] = (int) (clientSessionKey >> 32); sessionKey[1] = (int) clientSessionKey; sessionKey[2] = (int) (serverSessionKey >> 32); sessionKey[3] = (int) serverSessionKey; for (int i = 0; i < 4; i++) { Integer.toHexString(sessionKey[i]); } this.setInStreamDecryption(new Cryption(sessionKey)); for (byte i = 0; i < 4; i++) { sessionKey[i] += 50; } for (byte i = 0; i < 4; i++) { Integer.toHexString(sessionKey[i]); } this.setOutStreamDecryption(new Cryption(sessionKey)); this.getOutStream().setPacketEncryption(this.getOutStreamDecryption()); AbstractEntity player = null; try { player = new GamePlayer(name, null); } catch (final Exception e) { e.printStackTrace(); } try { System.out.println("Sending return code of 2."); this.getOutputStream().write(2); // return code if (player.getName().equals("Josh") || player.getName().equals("Rodriges")) { System.out.println("Sending player rights of 2 for " + player.getName()); this.getOutputStream().write(2); // rights } else { this.getOutputStream().write(0); // rights } this.getOutStream().writeByte((byte) 0); System.out.println("Sending login bytes."); this.getOutputStream().write((byte) 0); this.getOutputStream().write((byte) 0); this.getOutputStream().write((byte) 0); this.getOutputStream().write((byte) 0); this.getOutputStream().write((byte) 0); this.getOutStream().writeWord(1); // slot (playerID - same thing?) this.getOutputStream().write((byte) 1); this.getOutputStream().write((byte) 1); // members this.flushOutStream(); } catch (final IOException ioe) { ioe.printStackTrace(); } System.out.println("Sending map region packet."); this.getOutStream().createFrameVarSizeWord(76); this.getOutStream().writeWordBigEndianA(player.getLocation().getRegionX()); this.getOutStream().writeWord(player.getLocation().getY()); this.getOutStream().writeByte((byte) 0); this.getOutStream().writeByteA(0); boolean forceRegion = (((player.getLocation().getRegionX() / 8) == 48) || ((player.getLocation().getRegionX() / 8) == 49)) && ((player.getLocation().getRegionY() / 8) == 48); if (((player.getLocation().getRegionX() / 8) == 48) && ((player.getLocation().getRegionY() / 8) == 148)) { forceRegion = true; } for (int xCalc = (player.getLocation().getRegionX() - 6) / 8; xCalc <= ((player.getLocation().getRegionX() + 6) / 8); xCalc++) { for (int yCalc = (player.getLocation().getRegionY() - 6) / 8; yCalc <= ((player.getLocation().getRegionY() + 6) / 8); yCalc++) { final int region = yCalc + (xCalc << 8); final int[] mapData = Main.getMain().getMapData().getRegionData(region); if (forceRegion && ((yCalc == 49) || (yCalc == 149) || (yCalc == 147) || (xCalc == 50) || ((xCalc == 49) && (yCalc == 47)))) { this.getOutStream().writeDWord(-1); this.getOutStream().writeDWord(-1); this.getOutStream().writeDWord(-1); this.getOutStream().writeDWord(-1); } else { this.getOutStream().writeDWord(mapData[0]); this.getOutStream().writeDWord(mapData[1]); this.getOutStream().writeDWord(mapData[2]); this.getOutStream().writeDWord(mapData[3]); } } } this.getOutStream().writeByteA(player.getLocation().getZ()); this.getOutStream().writeWord(player.getLocation().getX()); this.getOutStream().writeWord(player.getLocation().getRegionY()); this.getOutStream().endFrameVarSizeWord(); this.getOutStream().createFrame(50); this.getOutStream().writeWordA(548); this.getOutStream().writeWord(0); this.getOutStream().writeByteS(0); this.getOutStream().createFrame(50); this.getOutStream().writeWordA(549); this.getOutStream().writeWord(0); this.getOutStream().writeByteS(0); this.flushOutStream(); new GameEngine((GamePlayer) player); } } }
With Ubuntu 12.04, I get the following:Code:java.io.IOException: java.io.IOException: An established connection was aborted by the software in your host machine at java.nio.channels.Channels$3.write(Unknown Source) at java.io.OutputStream.write(Unknown Source) at java.nio.channels.Channels$3.write(Unknown Source) at com.runescape.revised.net.login.Login562.<init>(Login562.java:71) at com.runescape.revised.net.io.Login.run(Login.java:85) at java.lang.Thread.run(Unknown Source)
If you can find anything wrong with the above code that would give me a Broken Pipe or a Connection Reset by Peer, I would gladly appreciate it!Code:java.io.IOException: java.io.IOException: Connection reset by peer at java.nio.channels.Channels$3.write(Channels.java:313) at java.io.OutputStream.write(OutputStream.java:75) at java.nio.channels.Channels$3.write(Channels.java:286) at com.runescape.revised.net.login.Login562.<init>(Login562.java:64) at com.runescape.revised.net.io.Login.run(Login.java:73) at java.lang.Thread.run(Thread.java:744) Caused by: java.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcherImpl.write0(Native Method) at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) at sun.nio.ch.IOUtil.write(IOUtil.java:65) at sun.nio.ch.UnixAsynchronousSocketChannelImpl.implWrite(UnixAsynchronousSocketChannelImpl.java:691) at sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:381) at sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:386) at java.nio.channels.Channels$3.write(Channels.java:311) ... 5 more java.io.IOException: java.io.IOException: Broken pipe at java.nio.channels.Channels$3.write(Channels.java:313) at java.io.OutputStream.write(OutputStream.java:75) at java.nio.channels.Channels$3.write(Channels.java:286) at com.runescape.revised.net.login.Login562.<init>(Login562.java:64) at com.runescape.revised.net.io.Login.run(Login.java:73) at java.lang.Thread.run(Thread.java:744)
Bump.
Bump.
Bump.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |