Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Getting SocketException from a ScriptMaster function that has worked for years

Featured Replies

In a system I built years ago, I register a ScriptMaster function with the following (obviously based on one of the ScriptMaster examples):

RegisterGroovy(
  "PostDataToURL( key1 ; value1 ; key2 ; value2 ; key3 ; value3 ; key4 ; value4 ; url )";

"// Construct data¶
String data = URLEncoder.encode( key1, \"UTF-8\") + \"=\" + URLEncoder.encode(value1, \"UTF-8\" );¶
data += \"&\" + URLEncoder.encode( key2, \"UTF-8\") + \"=\" + URLEncoder.encode(value2, \"UTF-8\" );¶
data += \"&\" + URLEncoder.encode( key3, \"UTF-8\") + \"=\" + URLEncoder.encode(value3, \"UTF-8\" );¶
data += \"&\" + URLEncoder.encode( key4, \"UTF-8\") + \"=\" + URLEncoder.encode(value4, \"UTF-8\" );¶

// Send data¶
URL url_obj = new URL( url );¶
URLConnection conn = url_obj.openConnection();¶
conn.setDoOutput( true );¶
OutputStreamWriter wr = new OutputStreamWriter( conn.getOutputStream() );¶
wr.write( data );¶
wr.flush();¶

// Get the response¶
String response = conn.getInputStream().getText( \"utf-8\" );¶
wr.close();¶
return response;";

"isGui=false"
)

The function is called with the following script step:

Set Field [ POR__Main::xml_response ;
Let(
  [
    _ob = "AAA00000000";

    _url = "http://connector.ob10.com/Suppliers/post.asp";

    _key1 = "Contents";
    _data1 = POR__Main::xml;

    _key2 = "OB10Number";
    _data2 = _ob;

    _key3 = "Username";
    _data3 = _ob;

    _key4 = "Password";
    _data4 = "abc"
  ];

  PostDataToURL( _key1; _data1; _key2; _data2; _key3; _data3; _key4; _data4; _url )
)

Starting yesterday, the script that executes the above step began giving an error. `SMLastError` returns `"java.net.SocketException: Connection reset"` while `SMLastStackTrace` returns the following:

java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(SocketInputStream.java:168)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
	at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:709)
	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:674)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1218)
	at sun.net.www.protocol.http.HttpURLConnection$getInputStream.call(Unknown Source)
	at Script1.run(Script1.groovy:16)
	at com.prosc.beanshell.GroovyFunction.invoke(GroovyFunction.java:125)
	at com.prosc.fmkit.Plugin.invokeFunction(Plugin.java:342)
	at com.prosc.fmkit.RegisterablePlugin.invokeFunction(RegisterablePlugin.java:146)
	at com.prosc.fmkit.Plugin.invokeFunctionNoErrors(Plugin.java:323)
	at com.prosc.fmkit.PluginBridge$4.run(PluginBridge.java:1289)
	at com.prosc.fmkit.PluginBridge.runTask(PluginBridge.java:1517)
	at com.prosc.fmkit.PluginBridge.doFunction(PluginBridge.java:1306)

All of my checking indicates nothing has changed in the function or the script. We are waiting to hear back from the vendor we're connecting to in order to see if there's anything that changed on their end, but that seems unlikely.

Why would this be happening and what can I do to resolve it?

Thanks,
Chuck

Edited by Chuck

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.