Getting an error.

25 views
Skip to first unread message

Tech Novice

unread,
Mar 17, 2023, 5:19:21 AM3/17/23
to OWASP ZAP Developer Group
Hi, 
After launching the browser getting an error as ZAP Error [org.apache.hc.core5.http.NoHttpResponseException]: "url" failed to respond.

below is the code.
public class ZAPUtil {

private static ClientApi clientApi;
public static Proxy proxy;
private static ApiResponse apiResponse;

private static final String zapAddress = "localhost";
private static final int zapPort = 8098;
private static final String apiKey = "";

static {
clientApi = new ClientApi(zapAddress, zapPort, apiKey);
proxy = new Proxy().setSslProxy(zapAddress + ":" + zapPort).setHttpProxy(zapAddress + ":" + zapPort);

}

public static void waitTillPassiveScanCompleted() {

try {
apiResponse = clientApi.pscan.recordsToScan();
String tempVal = ((ApiResponseElement) apiResponse).getValue();
while (!tempVal.equals("0")) {
System.out.println("passive scan is in progress");
apiResponse = clientApi.pscan.recordsToScan();
tempVal = ((ApiResponseElement) apiResponse).getValue();

}
System.out.println("pasive scan is completed");
} catch (ClientApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

public static  void generateZapReport(String site_to_test) {

String title = "Demo Title";
String template = "traditional-html-plus";
String theme = "dark";
String description = "Demo desp";
String contexts = null;
String sites = site_to_test;
String sections = null;
String includedconfidences = null;
String includedrisks = "High|Medium";
String reportfilename ="Demofilename";
String reportfilenamepattern= "{{yyyy-MM-dd}}-ZAP-Report-[[site]]";
String reportdir = System.getProperty("path");
String display = "true";

try {
clientApi.reports.generate(title, template, theme, description, contexts, sites, sections, includedconfidences, includedrisks, reportfilename, reportfilenamepattern, reportdir, display);
} catch (ClientApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
----------------------------------------------------------------
public class BaseClass {
public static WebDriver we;
private static DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
private static Date date = new Date();
private static String d = dateFormat.format(date);
private static String filename = "Summary" + d + ".html";


/**
 *
 * @throws IOException
 * @throws SQLException
 * @throws ClassNotFoundException
 */
@BeforeSuite
public void setUp() throws IOException, SQLException, ClassNotFoundException {
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(Constants.reportPath + filename);
extent = new ExtentReports();
extent.attachReporter(htmlReporter);
extent.setSystemInfo("HostName");
extent.setSystemInfo("Team");
extent.setSystemInfo("Browser", Utility.fetchPropertyValue("browserName"));

// @@@@@@@@@@@*******************************************************
if (Utility.fetchPropertyValue("path").equals("Yes")) {
ImportToMysql.convertXLSXIntoMYSQL(Utility.fetchPropertyValue("path"), "locators",
Utility.fetchPropertyValue("path"));
}

}

/**
 *
 */
@BeforeMethod
public void initiateDriverInstance() {
try {
if (Utility.fetchPropertyValue("browserName").toString().equalsIgnoreCase("chrome")) {

//ChromeOptions chrOptions = new ChromeOptions();
FirefoxOptions chrOptions = new FirefoxOptions();
chrOptions.setProxy(proxy);
chrOptions.setAcceptInsecureCerts(true);
//chrOptions.addArguments("--remote-allow-origins=*");
//WebDriverManager.chromedriver().setup();
WebDriverManager.firefoxdriver().setup();
//we = new ChromeDriver(chrOptions);
we = new FirefoxDriver(chrOptions);
we.manage().window().maximize();
we.get(Utility.fetchPropertyValue("applicationURL"));
}
} catch (Exception e) {
System.out.println("Unable to open Browser");
e.printStackTrace();
}
}

Tech Novice

unread,
Mar 17, 2023, 5:28:51 AM3/17/23
to OWASP ZAP Developer Group
Below is the ss aatached .
ZAPerror17032023.png

psiinon

unread,
Mar 17, 2023, 6:27:19 AM3/17/23
to OWASP ZAP Developer Group

Cheers,

Simon

Tech Novice

unread,
Mar 20, 2023, 1:59:41 AM3/20/23
to OWASP ZAP Developer Group
Hi Simon, 

 Yes, the issue was due to firewall as I tried same scenario on my local machine and I am able to intercept the browser. 

Thanks for the assistance!

psiinon

unread,
Mar 20, 2023, 6:10:45 AM3/20/23
to OWASP ZAP Developer Group
Thanks for letting us know!
Reply all
Reply to author
Forward
0 new messages