Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Connecting to Server from within Script


    SubCZ
     Share

    Recommended Posts

    I'm trying to connect to a locally run Redis Server from within my script to fetch machine learning solutions.

    I tested the connection and server in a standalone Java application and it works as expected, but when I try to establish the connection from within my script in the onStart() or onLoop() hooks, the script gets stuck trying to connect without throwing an exception.

    Is there some part of Dreambot that is preventing outgoing connections? I am not using a proxy and am currently using the free version of Dreambot to test it.

    I'm using the Jedis API to connect to the Redis server.

    Code below, although this exact code works when run from the main method of a standalone Java application:

    public int onLoop() {
    		if(!connected) {
    			log("Connecting...");
    			try {
    				Jedis jedis = new Jedis(IP);
    				log("Successfully connected to Server.");
    				log("PING: " + jedis.ping());
    				jedis.close();
    			}
    			catch(Exception e){
    				StringWriter sw = new StringWriter();
    	            e.printStackTrace(new PrintWriter(sw));
    	            String exceptionAsString = sw.toString();
    	            log(exceptionAsString);
    			}
    		}
    
    		return 1000;
    	}

     

    Link to comment
    Share on other sites

    40 minutes ago, SubCZ said:

    I'm trying to connect to a locally run Redis Server from within my script to fetch machine learning solutions.

    I tested the connection and server in a standalone Java application and it works as expected, but when I try to establish the connection from within my script in the onStart() or onLoop() hooks, the script gets stuck trying to connect without throwing an exception.

    Is there some part of Dreambot that is preventing outgoing connections? I am not using a proxy and am currently using the free version of Dreambot to test it.

    I'm using the Jedis API to connect to the Redis server.

    Code below, although this exact code works when run from the main method of a standalone Java application:

    public int onLoop() {
    		if(!connected) {
    			log("Connecting...");
    			try {
    				Jedis jedis = new Jedis(IP);
    				log("Successfully connected to Server.");
    				log("PING: " + jedis.ping());
    				jedis.close();
    			}
    			catch(Exception e){
    				StringWriter sw = new StringWriter();
    	            e.printStackTrace(new PrintWriter(sw));
    	            String exceptionAsString = sw.toString();
    	            log(exceptionAsString);
    			}
    		}
    
    		return 1000;
    	}

     

    If you are using maven build an uber/shadded/fat jar to bundle the depenencies with it.  Otherwise you need to create a /lib folder in your Dreambot folder and include the jars there.  Hmu if its still fucked.

     

    If you aren't using maven here are a couple resources if you want to use it to manage deps/build your scripts
     

    Dreambot Maven Submodules as scripts setup -> https://github.com/yeetware/DB-Maven

     

     

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.