我正在制作一个Android测试应用,它只是将一个String发送到服务器,该服务器是AWS EC2上的一个实例。然而,即使IP是正确的,我也看到了404。还有什么可能是错的?
URL serverUrl = new URL("http://aa.bb.cc.dd");
connection = (HttpURLConnection) serverUrl.openConnection();
connection.setRequestMethod("GET");
OutputStream stream = connection.getOutputStream();
String testString = "test123";
byte[] bytes = testString.getBytes();
stream.write(bytes);
stream.flush();
int retcode = connection.getResponseCode();
retcode是404.
在服务器端,我在所使用的安全组中允许以下所有来源: 所有TCP,端口0 - 65535 HTTP,端口80