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 6083973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:27:58+00:00 2026-05-23T11:27:58+00:00

FOUND SOLUTION (consider this closed and answered since I can’t answer my own question

  • 0

FOUND SOLUTION (consider this closed and answered since I can’t answer my own question before 7 hours). I had left an unnecessary Socket instanciation and it made the clien apps hang. Sorry for bothering all of you for this and thanks for the effort put in helping me run around searching for the issue =) Love you all!

I am getting nuts finding the solution to this “problem”. I have an bank simulation application that needs to simulate bank transfers between multiple branches of a bank. I currently use an event bus that dispatches different events objects that are caught by the clients’ connector object. If the client listens to the event received, it will call a command object and update whatever it needs to update and so on (just so you get a big picture).

Now, for some reason I cannot understand, my first client instance opens fine, and behaves just as expected, but any client instances opened after the first one will hang in these lines (variables are declared prior to being initialized):

try {
        s = new Socket(ip, port);
        System.out.println("Creating out stream");

        oos = new ObjectOutputStream(s.getOutputStream());
        oos.flush();
        System.out.println("Flushed data...");

        ois = new ObjectInputStream(s.getInputStream());

        //Below never gets printed on second client instance *sigh*
        System.out.println("HURRAY");
        readStream = new ReadEventFromStream(ois, this);
    } catch(IOException ioe) {
        ioe.printStackTrace();
        System.out.println("Can't connect to server.");
        System.exit(1);
    }

There is no exception thrown, no nothing…the second, third, … instances launched will just never get past these quite simple lines. Just so you know, the above code is called in the EventBusConnector(…) object instanciated by the client main’s function. Here is the ReadEventFromStream class making use of the command objects as stated before:

class ReadEventFromStream extends Thread {
private ObjectInputStream ois;
private EventBusConnector eventBusConn;
public ReadEventFromStream(ObjectInputStream ois, EventBusConnector eventBusConn) {
    this.ois = ois;
    this.eventBusConn = eventBusConn;
}

@Override
public void run() {
    while(true) {
        try {
            Object o = ois.readObject();
            if (eventBusConn.listensToEvent(o)) {
                Command command;
                if( o instanceof EventBranchListUpdate ) {
                    EventBranchListUpdate event = (EventBranchListUpdate) o;
                    command = new UpdateBranchListCommand(event, EventBusConnector.branch);
                    command.execute();
                } else if ( o instanceof EventNewBranch ) {
                    EventNewBranch event = (EventNewBranch) o;
                    command = new NewBranchCommand(event, this.eventBusConn);
                    command.execute();
                } else if( o instanceof EventMoneyTransfer ) {
                    EventMoneyTransfer event = (EventMoneyTransfer) o;
                    command = new MoneyTransferCommand(event, EventBusConnector.branch);
                    command.execute();
                }
            }
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}

}

So humm…yeah…I’ve been smashing my heading on this for hours and I really need some help because I’m getting nuts with this. If you need more code I will paste it. Thanks =)

  • 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-05-23T11:27:59+00:00Added an answer on May 23, 2026 at 11:27 am

    Oh well…after 8 hours of hard debugging, I found that the problem was my little self. I had left an unnecessary Socket instanciation roaming somewhere in the hidden corners of a class called by the client application…which made it hang. Sorry for bothering you all with this, I hesitated 8 hours to post it because I knew this was a complex application to debug when one is not writing the code…and I’m finding that thg

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found the solution for this question in C# , but I can't translate
Edited to Add * I haven't found a solution for this one yet, can
I edited this question after i found a solution... i need to understand why
Edited: SOLUTION FOUND. This is strange and not the best solution, but I just
I found this solution which works, but I find it hard to believe there
Following the solution found at Can I access session state from an HTTPModule? ,
problem euler #5 i found the solution but i don't know why this first
I have searched for hours now and haven't found a solution for my problem.
I've been looking around for a solution to this, but haven't quite found one.
I've tried googling for a solution to this problem but haven't yet found one.

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.