Proxy Issues

Cannot connect to internet when Sahi is not running

symptom After installing Sahi, I cannot connect to the internet from any browser when Sahi is not running.

Even though Sahi is not running, all browsers show that proxy settings have been set to point to Sahi's proxy.
cause To understand why this may be happening, some background information is in order.

Sahi needs to change system/browser proxy settings in order to work with browsers. This lets Sahi inject Sahi script in web pages that in turn allows Sahi to record and playback scripts on the page.

Sahi reverts the proxy settings when it closes.

But there may be some scenarios when this does not happen.

Before looking at these scenarios, let us see how IE, FireFox and Chrome differ in the proxy behavior.

Firefox and Chrome

When a Firefox or Chrome browser is opened from the Sahi Dashboard, it is opened in a separate profile. Proxy settings are changed only for that profile. What this means is that if you were to open a Firefox, Chrome or IE browser outside of the Sahi Dashboard at the same time, they will NOT go through the Sahi proxy. Thus a user will be able to access the internet directly from the latter browser session(s) like he/she normally does.

IE is different

When an IE browser is opened from the dashboard, the system proxy settings are modified to go through Sahi.
  • If you were to open an IE browser from outside the Sahi dashboard at the same time, it will go through the Sahi proxy since the system proxy has been modified.
  • If you were to open a Chrome browser from outside the Sahi dashboard at the same time, it will go through the Sahi proxy since Chrome uses the system proxy settings.
  • If you were to open a Firefox browser from outside the Sahi dashboard at the same time, it will go through the Sahi proxy if it is configured to use the system proxy settings.
For all such browsers that go through the Sahi proxy, the user may see some anamolous behavior. So if you wish to browse the internet, do so after closing the Sahi IE window.

Why am I unable to connect to the internet despite closing Sahi?

You can get into the above problem by doing the following steps in order.
  1. Start the Sahi server.
  2. Then launch an IE browser from the Sahi Dashboard and navigate to your application.
  3. Instead of closing the IE browser, close Sahi in either of these ways
    • Do Ctrl + C on the Sahi server command window
    • Or simply close it by pressing the Close (x) button on the Sahi server command window (not on the Sahi Dashboard).
Explanation

The system proxy settings are reverted under the following circumstances.
  • When the last IE browser window launched from Sahi (Dashboard, Testrunner, Ant etc) is closed.
  • When the Sahi Dashboard is closed (by clicking the Close(x) button on the Sahi Dashboard).
In the case described above, since the IE window was not closed, the proxy settings were not reverted. Also the user did not close the Sahi Dashboard but instead closed the Sahi server command window. Even if the IE window was closed after this, the proxy settings will not be reset.

Effect

Since the system proxy settings were not reverted, any browser using the system proxy settings will NOT be able to connect to the internet unless Sahi is running.
resolution We need to revert the system proxy settings.

You can do any of the following to achieve this.
  • Launch Sahi, open an IE browser, close the IE browser
  • Launch Sahi and close it by clicking the Close(x) button on the Sahi Dashboard.
  • Launch Sahi and click System Proxy Off from the Sahi Dashboard. This is the least recommended solution, since you should never toggle the System Proxy from the Dashboard under normal circumstances.

Cannot connect to Sahi proxy from firefox after changing the proxy port

symptom Firefox will show "The proxy server is refusing connections" message when you launch the firefox from Sahi.
cause Changing the proxy port number will cause this issue in the firefox browser as the previous port number is set in the firefox profiles.
resolution The issue gets resolved after deleting firefox profiles. So delete <Sahi Pro>/userdata/browser/ff/profiles folder. When Sahi Pro starts next time it will create the profiles with the correct port number.

'Server not found' error occurs on launching the Mozilla Firefox browser.

symptom The Sahi Start page does not open on launching the Mozilla Firefox browser from the Sahi Dashboard. Instead, it shows an error with the message "We can't connect to the server".
cause In order to work with browsers, Sahi changes browser proxy settings and sets it as Sahi Proxy. Sahi Proxy by default is set as 127.0.0.1:9999.

This issue occurs when Sahi Proxy is not set in the browser proxy settings. To confirm, open settings for Mozilla Firefox and verify if Sahi proxy is set in the proxy settings.
resolution To fix this, follow the below steps.
  1. Open the installation directory for Mozilla Firefox.
    • The default installation directory for Mozilla Firefox in Windows is C:\Program Files\Mozilla Firefox.
    • The default installation directory for Mozilla Firefox in Linux is /usr/lib/firefox-<version>.
  2. Open Mozilla.cfg file.
  3. Search for network.proxy.type. In the found line, replace 'pref' with 'defaultPref'.
      For example, change pref("network.proxy.type", 4); to defaultPref("network.proxy.type", 4);.
  4. Save the file. If unable to save, open the Mozilla.cfg file in administrator mode, do the above changes, and save.