getOutputStream()上的SocketException

时间:2014-08-19 17:28:22

标签: java tcp smartystreets

我试图让链接的示例代码工作,但遇到SocketException(下面)。我正在使用java 7。

https://github.com/smartystreets/LiveAddressSamples/blob/master/java/LiveAddressExample.java

IO Exception Error: java.net.SocketException: Connection reset
Exception in thread "main" java.lang.NullPointerException
    at com.icat.coastal.processor.SmartyStreetAddress.main(SmartyStreetAddress.java:71)

我认为这是由于这一行:

DataOutputStream outgoing = new DataOutputStream(urlConn.getOutputStream());

我尝试按照此处的建议调整防火墙,但它不起作用:http://www.javaprogrammingforums.com/java-networking/17319-java-net-socketexception-connection-reset.html

如何深入挖掘以确定问题,或者您认为哪些错误?

1 个答案:

答案 0 :(得分:0)

我刚试了一次新的尝试,直接从github示例复制并插入我的auth-idauth-token。这是我的终端会议的样子:

$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

$ ll
drwxr-xr-x   6 mike  staff   204B Feb  9 11:49 ./
drwxr-xr-x  18 mike  staff   612B Dec 22 23:01 ../
-rw-r--r--   1 mike  staff   3.2K Feb  9 11:49 LiveAddressExample.java
-rw-r--r--   1 mike  staff   349B Dec 22 23:01 README.md
-rw-r-----@  1 mike  staff    23K Feb  9 11:45 json-simple-1.1.1.jar

$ javac -cp json-simple-1.1.1.jar LiveAddressExample.java 
Note: LiveAddressExample.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: LiveAddressExample.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

$ java -cp .:json-simple-1.1.1.jar LiveAddressExample
3785 Las Vegas Blvd S
Las Vegas NV 89109-4333

1600 Amphitheatre Pkwy
Mountain View CA 94043-1351

所以此时我无法复制错误。我的一个同事尝试使用java 1.6做同样的事情,这也很有用。您是否还有其他有关您的环境的详细信息或与您对代码所做的修改相关的任何详细信息?