Gemfire 的 Http 响应无效?

http://img1.mukewang.com/616bd8490001c7e005980488.jpg

public class GemfireTest extends SecurityManager {


            public static void main(String[] args) throws NameResolutionException, TypeMismatchException, QueryInvocationTargetException, FunctionDomainException, IOException {


                System.setProperty("gemfire.locators", "localhost[8091]");

                Properties properties = new Properties();


             ServerLauncher serverLauncher = new ServerLauncher.Builder()


                        .setMemberName("server1")

                        .setServerPort(40404)

                        .set("start-locator", "localhost[8091]")

            .build();

                serverLauncher.start();

                System.out.println(serverLauncher.status());

String restapi ="http://localhost:8091/gemfire-api/v1/";

             //   URLConnection urlConnection = new URL(restapi).openConnection();

                try {

                    URL obj = new URL(restapi);

                    HttpURLConnection con = (HttpURLConnection) obj.openConnection();

                    con.setRequestMethod("GET");

                    con.setRequestProperty("accept","application/json");

                    int responseCode = con.getResponseCode();

                    System.out.println(responseCode);

                   // if (responseCode == HttpURLConnection.HTTP_OK) { // success

                        BufferedReader in = new BufferedReader(new InputStreamReader(

                                con.getInputStream()));

                        String inputLine;

                        StringBuffer response = new StringBuffer();


                        while ((inputLine = in.readLine()) != null) {

                            response.append(inputLine);

                        }

                        in.close();


                        // print result

                        System.out.println("reason"+response.toString());


获取响应代码:-1,无效的 Http 响应。


我该如何解决这个问题?


UYOU
浏览 160回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java