Python smtplib error: getaddrinfo returns an empty list - sockets

I have a python application where I am using SMTP to send email. We are using IronPython 2.7
The function call is like this
smtplib.SMTP(SMTP_HOST, SMTP_PORT)
Inside smtplib.SMTP there is self.connect(host, port) where it calls self._get_socket(host, port, self.timeout) and returns socket.create_connection((port, host), timeout)
The socket.create_connection((port, host), timeout) gives me an error : getaddrinfo returns an empty list
This issue happens intermittently not all the time, so what could be the issue?

Related

How to establish a server with a unix domain socket

I am trying to establish a server with OCaml using a unix domain socket. I tried the following:
let sock_addr = Unix.ADDR_UNIX sock_file_path in
Unix.establish_server server_loop sock_addr;
With sock_file_path being a path to a .sock file.
But I always get one of the following errors:
if the file in sock_file_path doesn't exist, the exception Unix.EPERM is raised (Operation not permitted).
if the file in sock_file_path exists and is just an empty file, the exception Unix.EADDRINUSE is raised (Address already in use).
In both cases, it is the call to bind that raises the exception in Unix.establish_server.
Is there a particular way in which the file needs to be initialized for it to work?

Not able to run azure logic apps locally using VScode and Azurite

I am using VSCode to create and test my logic apps locally. I have created a simple HTTP trigger and response for it. I have installed all the components and versions correctly. I am getting below error when I run my logic apps,
**Workflow Error: operationName='WorkflowDefinitionProvider.ProcessWorkflow', message='Workflow 'test-1' validate and create workflow failed, the error is 'One or more errors occurred. (Unexpected HTTP status code 'NotFound'.) (Unexpected HTTP status code 'NotFound'.)'', exception='System.AggregateException: One or more errors occurred. (Unexpected HTTP status code 'NotFound'.) (Unexpected HTTP status code 'NotFound'.)
[2022-05-03T02:52:23.134Z] ---> Microsoft.WindowsAzure.Storage.StorageException: Unexpected HTTP status code 'NotFound'.
[2022-05-03T02:52:23.136Z] ---> System.Net.WebException: The remote server returned an error: (404) Not Found.**
It is also giving me below error in the logs,
**ErrorCode:
[2022-05-03T03:08:44.593Z] ', extensionVersion='1.0.0.0', siteName='UNDEFINED_SITE_NAME', slotName='', activityId='00000000-0000-0000-0000-000000000000'.
[2022-05-03T03:08:44.595Z] The listener for function 'Functions.WorkflowDispatcher' was unable to start.
[2022-05-03T03:08:44.595Z] The listener for function 'Functions.WorkflowDispatcher' was unable to start. Microsoft.WindowsAzure.ResourceStack: Unexpected HTTP status code 'NotFound'. The remote server returned an error: (404) Not Found.**
The process to test that I am following,
Start azurite in VSCode
and then Execute function - func host start
Anyone has any clue or faced similar problems? I am using logic apps first time.
To be able to test HTTP triggers locally you need to
"To locally run webhook-based triggers and actions, such as the built-in HTTP Webhook trigger, in Visual Studio Code, you need to set up forwarding for the callback URL."
https://learn.microsoft.com/en-us/azure/logic-apps/create-single-tenant-workflows-visual-studio-code

Flutter Unhandled Exception: SocketException: OS Error: Broken pipe, errno = 32, address = 10.0.2.2, port = 51420

I am using Flutter with Flask at back end. I want to send an image from flutter to Flask for processing.
enter image description here
But I am getting this error in Android studio:
[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: SocketException: OS Error: Broken pipe, errno = 32, address = 10.0.2.2, port = 51420
My flask terminal says:
127.0.0.1 - - [11/May/2021 23:07:56] "←[37mPOST / HTTP/1.1←[0m" 200 -
Your server process has received a SIGPIPE writing to a socket. This usually happens when you write to a socket fully closed on the other (client) side. This might be happening when a client program doesn't wait till all the data from the server is received and simply closes a socket (using close function).
In a C program you would normally try setting to ignore SIGPIPE signal or setting a dummy signal handler for it. In this case a simple error will be returned when writing to a closed socket. In your case a python seems to throw an exception that can be handled as a premature disconnect of the client.

NodeMCU crashes when attempting to call net.socket:connect()

I am attempting to send a broadcast packet to a certain port, but it seems that the code gives some weird errors for which I can't find a fix.
I've tried using net.socket:connect() and then calling the "send()" method, which didn't work, then I said that I should use the net.socket:on('connection') and send there, since I suppose net.socket:connect() isn't synchronous. But that gave a weird error too...
For this code:
function sendBroadcastPacket()
bip = wifi.sta.getbroadcast()
srv = net.createConnection(net.UDP,0)
print('Trying to connect on: ', bip)
srv:connect('9001', bip)
srv:send("Broadcast packet from: "..NODE_ID, function(sent)
print("Broadcasted packet! "..sent)
end)
end
I receive the following error:
PANIC: unprotected error in call to Lua API (init.lua:24: attempt to
call method 'connect' (a nil value))
Line 24 is the srv:connect line.
After that I tried listening for the connection event first, to see if it worked that way:
function sendBroadcastPacket()
bip = wifi.sta.getbroadcast()
srv = net.createConnection(net.UDP,0)
print('Trying to connect on: ', bip)
srv:on('connection', function(sck, c)
sck:send("Broadcast packet from: "..NODE_ID, function(sent)
print("Broadcasted packet! "..sent)
end)
end)
srv:connect('9001', bip)
end
I receive the following error:
PANIC: unprotected error in call to Lua API (init.lua:24: invalid
callback name)
Line 24 is the srv:on('connection') line.
What seems to be happening here? There aren't many google results, since a lot of other people use the Arduino-IDE version(btw, is that still nodemcu or do you need a different firmware for the ESP8266?).
I am getting a broadcast IP, and it connects to the AP. I didn't post here the wifi connection part because it works, I've used it to test mqtt and http connections which worked.
The build I'm using, Lua 5.1.4 on SDK 2.1.0(116b762), has the net module included.
Your attempts all failed because you don't seem to consider that UDP is a connection-less protocol. Hence, there's no connect() or on('connection'... for UDP.
The first attempt failed because send() needs to be called on a socket and not on the connection. The second failed because the connection callback name is only available for TCP, not for UDP.
Try something like this:
function sendBroadcastPacket()
local port = 9001
local bip = wifi.sta.getbroadcast()
print(string.format("Broadcasting to %s:%d", bip, port))
net.createUDPSocket():send(port, bip, "foo bar")
end
Documentation: https://nodemcu.readthedocs.io/en/latest/en/modules/net/#netudpsocket-module

Error using SoapClient() in PHP

I'm trying to access WSDL(Web Service Definition Language) file using SoapClient() of PHP. I found that WSDL file is authenticated. I tried with passing credentials on an array by another parameter and active SSL on my server, still I'm getting an error.
Here is the code I'm using:
$client = new
SoapClient("https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl",array("trace"
=> "1","Username" => "username","Password" => "password"));
Here is the error I'm getting:
Warning:
SoapClient::SoapClient(https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl)
[soapclient.soapclient]: failed to open stream: Connection timed out
in PATH_TO_FILE on line 80
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning
: failed to load external entity
"https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl"
in PATH_TO_FILE on line 80
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Couldn't load from
'https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl'
: failed to load external entity
"https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl"
in PATH_TO_FILE:80 Stack trace: #0
/home2/wingstec/public_html/widget/API/index.php(80):
SoapClient->SoapClient('https://webserv...', Array) #1 {main} thrown
in PATH_TO_FILE on line 80
It seems that error says file not exist at the path we given but when we run that path directly on browser then we're getting that file
Can anyone help me to figure out what the exactly problem is?
First make sure you have the right to access website from your hosting account or server - check first if you can access a http webservice (without the s). If not, check if allow_url_fopen is set to true in php.ini.
Then, if you are trying to establish a https connection, you need a local certificate.
See if you can add one and instantiate your Soap object using something like
new SoapClient($wsdl, array('local_cert' => $pathToLocalCert));