I want to ckeck if an URL can be reached or not, otherwise I print an error message to the user.
Here is my code
URL url = new URL("http://127.0.0.1:8080/booksManager");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
System.out.println(connection.getResponseMessage());
This code throws an error and doesn't print anything on the console.
error logs
Related
I'm having trouble defining a message in the Gmail login code when the credentials are wrong.
def connect():
imap_host = 'imap.gmail.com'
email = 'cryp#gmail.com'
password = input("Password: ")
M = imaplib.IMAP4_SSL(imap_host)
M.login(email, password)
try:
os.system('cls')
print('Connected.')
except imaplib.IMAP4.error:
os.system('cls')
print('Failed to connect.')
connect()
Below is the message that appears.
raise self.error(dat[-1])
imaplib.error: b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)'
and not this:
print('Falha ao Conectar.')
The message Connected appears correctly when I type the email and password correctly, however when I make an error this message appears instead of Failed to connect.
I currently am unable to authorize the SquareReaserSDK with iOS (Swift).
I have a node instance that takes in an access_token.
I then call listLocations()
I provide the first location_id in the body of a CreateMobileAuthorizationCodeRequest()
I then pass the resulting mobile auth code to the client
After successfully retrieving a mobile auth token and providing that to the below, the first time this is called there is no callback. The block if statement never fires.
Redundant calls results in an authorization_already_in_progress error (the if statement is fired).
SQRDReaderSDK.shared.authorize(withCode: mobileAuthToken) { location, error in
if let authError = error {
print("Authorize SquareReaderSDK", authError.localizedDescription)
} else {
print("Authorize SquareReaderSDK", location)
Defaults[.establishment]?.squareMobileAuthToken = mobileAuthToken as! String
}
}
authorize() endpoint reference: https://developer.squareup.com/docs/api/reader/ios/Classes/SQRDReaderSDK.html#/Authorization
Redundant calls results in:
vvvvv SQUARE ERROR vvvvv
ERROR: Something went wrong. Please contact the developer of this application and provide them with this error code: authorization_already_in_progress
DEBUG CODE: authorization_already_in_progress
DEBUG MESSAGE: Authorization is already in progress. Please wait for SQRDReaderSDK.shared.authorize() to complete.
^^^^^ SQUARE ERROR ^^^^^
At any point while trying to authorize the device, I get the following error when trying to present the checkoutController:
Checkout Failed:
This device is not currently authorized to accept payments with Square.
I'm trying to do Browser-based upload from android. In the first steps, the mobile asks my server to get a url and token from youtube. after the mobile got if from the server, the mobile uploads the video to youtube. But sometimes a "Connection Reset By Peer" exception is thrown, after the video was uploaded and can be seen on youtube. How can I avoid this error, or at least check if the video was uploaded correctly?
and another thing, I don't get the youtube_VideoId in the response (in the case there is no exception).
this is the code for the uploading step:
File file = new File(fileName);
try {
HttpClient client = new DefaultHttpClient();
String postURL = url + "?nexturl=http://example.com";
HttpPost post = new HttpPost(postURL);
FileBody bin = new FileBody(file);
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("email", new StringBody("XXX#gmail.com", "text/plain", Charset.forName("UTF-8")));
reqEntity.addPart("token", new StringBody(token));
reqEntity.addPart("uploadfile", bin);
this.totalSize = bin.getContentLength();
post.setEntity(reqEntity);
HttpResponse response = client.execute(post);
HttpEntity resEntity = response.getEntity();
Connection reset maybe a happening if there are really long videos. I know there was a bug open for more than an hour connections.
You can check YouTube direct Lite for Android project to poll about video status and processing status.
I have downloaded the sample code of the below path
http://www.codeproject.com/Articles/143669/Manage-YouTube-using-C-and-Youtube-API-1-6
Then I have installed the YouTube_SDK_2.1.0.0.msi
Now I can build the project successfully, but when I want to search a video in the Youtube
the AtomFeed of the videofeed will return the Error=NoLinkedYouTubeAccount
Please tell me what happened, I already surveyed some days in network.
Sample code list as below
yousettings = new YouTubeRequestSettings("My AP", devkey, username, password);
yousettings.Credentials.AccountType = "GOOGLE";
.........
videofeed = yourequest.Get<Video>(new Uri(feedUrl));
videofeed will always return fail then the Sample Ap will be crashed, the crash info list as below:
An unhandled exception of type
Google.GData.Client.GDataRequestException occurred in
Google.GData.Client.dll Additional information: Execution of request
failed:
http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today
Note:
I have link the Youtube account to the Google account.
I try to modify the yousettings.Credentials.AccountType = "GOOGLE";
FeedUri = "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today"
I try to send messsage to rabbitmq-server:
send_message(Channel, Host, Password, Message) ->
amqp_channel:cast(Channel, #'basic.publish'{exchange = <<"">>},
routing_key = <<"test">>,
#amqp_msg{payload = Message}).
But get error:
Error in process <0.431.0> with exit value:
{function_clause,[{gen_server,cast, [2,{cast,{'basic.publish',0,<<0
bytes>>,<<7 bytes>>,false,false},
{amqp_msg,{'P_basic',undefined,undefined,undefined,undefined,undefined,undefined,
undefined,undefined,undefined,undefined,undefined...
How can i fix it? How can i correctly send message to rabbitmq-server?
Thank you.
Check the value of Channel: from the stacktrace it shows that it is equal to 2, which is not a valid Pid.
The code calling send_message/4 must do something funky and not pass a valid Channel to it.