openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

connect exception

Open amszsthl opened this issue 2 years ago • 2 comments

image

How can i fix this issue?

''' Exception in thread "main" java.lang.RuntimeException: java.net.ConnectException: Failed to connect to api.openai.com/2001:0:0:0:0:0:480e:cf5f:443 at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:45) at io.reactivex.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:90) at io.reactivex.Single.blockingGet(Single.java:2002) at com.theokanning.openai.service.OpenAiService.execute(OpenAiService.java:217) at com.theokanning.openai.service.OpenAiService.createCompletion(OpenAiService.java:88) at example.OpenAiApiExample.main(OpenAiApiExample.java:20)

'''

computer:Apple M1 system: Mac OS IDE:IntelliJ IDEA 2022.2.1 (Community Edition)

Thanks!

amszsthl avatar Mar 04 '23 13:03 amszsthl

This is the IP I get:

PS F:\workspace\openai-java> nslookup api.openai.com
Server:  dns-cac-lb-01.rr.com
Address:  2001:1998:f00:1::1

Non-authoritative answer:
Name:    api.openai.com
Address:  52.152.96.252

cryptoapebot avatar Mar 04 '23 14:03 cryptoapebot

@cryptoapebot 😄 Thanks for your reply. The sample project is work now. Due to the API not being open to China, my solution was to set the proxy to global mode.

amszsthl avatar Mar 04 '23 15:03 amszsthl

my solution was to set the proxy to global mode.

@amszsthl ,Should you please tell me the detail of set the proxy to global mode? I faced up the same problems.Thanks in advance.

w00189670 avatar May 01 '23 03:05 w00189670