Jump to content
Sign in to follow this  

Getting SocketException from a ScriptMaster function that has worked for years

Recommended Posts

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

  "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 );¶

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


The function is called with the following script step:

Set Field [ POR__Main::xml_response ;
    _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?


Edited by Chuck

Share this post

Link to post
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
Sign in to follow this  


Important Information

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