I have a simple piece of code that creates a MySQL connection:
MYSQL *conn = mysql_init(NULL);
if(conn == NULL){
fprintf(stderr, "Error: can't create MySQL-descriptor\n");
exit(1);
}
if(!mysql_real_connect(conn,"my_host.com","my_server","psw",NULL,NULL,NULL,0)){
fprintf(stderr, "Error: can't connect to database %s\n", mysql_error(conn));
} else {
fprintf(stdout, "MySQL connect Success!\n");
}
mysql_close(conn);
The valgrind says:
==3283== LEAK SUMMARY:
==3283== definitely lost: 0 bytes in 0 blocks
==3283== indirectly lost: 0 bytes in 0 blocks
==3283== possibly lost: 0 bytes in 0 blocks
==3283== still reachable: 61,512 bytes in 17 blocks
==3283== suppressed: 0 bytes in 0 blocks
It is an actual memory leak?
Related
similar issue Firebase Messaging: app/network-timeout (Error while making request: timeout of 10000ms exceeded) but i didnt solve with anything.
here is my configuration
const options = {
priority: "high",
timeToLive: 60 * 60 * 24
};
// i have an option like that
const headLine = 'hello' // under 30 characters
const message_notification = {
notification: {
title: 'title not long sometimes under 15 - 20 characters',
body: headLine,
url: req.body.url,
// other: 'other data',
// tag: req.body.tag,
}
};
// i use sendToTopic
package.json
"firebase-admin": "^11.0.0",
what should i do ? what best practice to sent a notification ?
should i make it queue ? or just make dead lock ( infinity loop ) until success on sent notification ?
sometimes work sometimes timeout like that .
i have already deploy (production) on VPS Server.
➜ ~ uname -a
Linux xxxx 5.4.0 #1 SMP Tue Jan 25 12:49:12 MSK 2022 x86_64 x86_64 x86_64 GNU/Linux
➜ ~ cat /proc/meminfo
MemTotal: 3145728 kB
MemFree: 1884388 kB
MemAvailable: 2210944 kB
Cached: 305012 kB
Buffers: 0 kB
Active: 737292 kB
Inactive: 423988 kB
Active(anon): 550516 kB
Inactive(anon): 310112 kB
Active(file): 186776 kB
Inactive(file): 113876 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 4 kB
Writeback: 0 kB
AnonPages: 860628 kB
Shmem: 4360 kB
Slab: 68948 kB
SReclaimable: 25904 kB
SUnreclaim: 43044 kB
The following node.js script scans all ports for a custom FTDI device and once the device is found, it checks its serial number and temperature. console.log shows:
Serial number: 1003
Temperature: 28
If I unplug the device I get the following error: Port closed: bad file descriptor. When I re-plug the device I get some undefined behaviour. Sometimes I get the correct serial number but an incorrect temperature:
Serial number: 1003
Temperature: 0
Sometimes I get the reply unknown command from the device (code is not shown in the snippet below). However if I debug the script in Visual Studio Code, set a breakpoint at ftdiPort = new serialPort(path, {baudRate: 115200}); and wait 4+ seconds to go on after reconnecting the device, I get the correct data.
Code:
'use strict';
const serialPort = require('serialport');
let ftdiPort;
searchFtdiPort();
//Check all ports every 1 second if device is connected
function searchFtdiPort() {
let checkPorts = setInterval(function() {
serialPort.list().then(ports => {
for(let i = 0; i < ports.length; i++) {
if(ports[i].manufacturer == 'FTDI') {
openFtdiPort(ports[i].path);
clearInterval(checkPorts);
break;
}
}
});
}, 1000);
}
//When device is connected, open port and ask for serial number and temperature
function openFtdiPort(path) {
ftdiPort = new serialPort(path, {baudRate: 115200});
let Readline = require('#serialport/parser-readline');
let parser = ftdiPort.pipe(new Readline({delimiter: '\n'}));
ftdiPort.on('open', function() {
getSerial(path);
getTemperature(path);
});
ftdiPort.on('error', function(error) {
console.log('Port error: ', error.message);
});
ftdiPort.on('close', function(info) {
console.log('Port closed: ', info.message);
searchFtdiPort();
});
parser.on('data', function(data) {
parseFtdiData(data);
});
}
function parseFtdiData(data) {
let key = res[0];
let value = res[1];
switch(key) {
case 'serial':
console.log('Serial number:', value);
break;
case 'fmcw_temp':
console.log('Temperature:', value);
break;
default:
console.log('Key not specified.');
break;
}
}
function getSerial(path) {
let serialCmd = 'get_serial\n';
ftdiPort.write(serialCmd, function(error) {
if(error) {
console.log('Writing on port failed: ', error.message);
return;
}
console.log('Write', serialCmd, 'on', path);
});
}
function getTemperature(path) {
let serialCmd = 'fmcw_temp\n';
ftdiPort.write(serialCmd, function(error) {
if(error) {
console.log('Writing on port failed: ', error.message);
return;
}
console.log('Write', serialCmd, 'on', path);
});
}
DEBUG information on Linux (here I get unknown command instead of temperature=0 for example):
user#linux-ayq9:~/Desktop/Service> DEBUG=* node test.js
serialport/bindings loading LinuxBinding +0ms
serialport/stream .list +0ms
serialport/stream opening path: /dev/ttyUSB0 +51ms
serialport/binding-abstract open +0ms
serialport/stream _read queueing _read for after open +1ms
serialport/bindings/poller Creating poller +0ms
serialport/stream opened path: /dev/ttyUSB0 +0ms
serialport/stream _write 11 bytes of data +1ms
serialport/binding-abstract write 11 bytes +2ms
serialport/stream _read reading { start: 0, toRead: 65536 } +0ms
serialport/binding-abstract read +1ms
serialport/bindings/unixWrite Starting write 11 bytes offset 0 bytesToWrite 11 +0ms
serialport/bindings/unixRead Starting read +0ms
serialport/bindings/unixWrite write returned: wrote 11 bytes +0ms
serialport/bindings/unixWrite Finished writing 11 bytes +1ms
serialport/stream binding.write write finished +2ms
serialport/stream _write 10 bytes of data +0ms
serialport/binding-abstract write 10 bytes +1ms
Write get_serial
on /dev/ttyUSB0
serialport/bindings/unixWrite Starting write 10 bytes offset 0 bytesToWrite 10 +0ms
serialport/bindings/unixRead read error { [Error: EAGAIN: resource temporarily unavailable, read] errno: -11, code: 'EAGAIN', syscall: 'read' } +1ms
serialport/bindings/unixRead waiting for readable because of code: EAGAIN +0ms
serialport/bindings/poller Polling for "readable" +3ms
serialport/bindings/unixWrite write returned: wrote 10 bytes +1ms
serialport/bindings/unixWrite Finished writing 10 bytes +0ms
serialport/stream binding.write write finished +1ms
Write fmcw_temp
on /dev/ttyUSB0
serialport/bindings/poller received "readable" +16ms
serialport/bindings/unixRead Starting read +16ms
serialport/bindings/unixRead Finished read 48 bytes +0ms
serialport/stream binding.read finished { bytesRead: 48 } +15ms
Serial number: 1003
Temperature: 28
serialport/stream _read reading { start: 48, toRead: 65488 } +0ms
serialport/binding-abstract read +16ms
serialport/bindings/unixRead Starting read +0ms
serialport/bindings/unixRead read error { [Error: EAGAIN: resource temporarily unavailable, read] errno: -11, code: 'EAGAIN', syscall: 'read' } +1ms
serialport/bindings/unixRead waiting for readable because of code: EAGAIN +0ms
serialport/bindings/poller Polling for "readable" +1ms
serialport/bindings/poller error [Error: bad file descriptor] +3s
serialport/stream binding.read error [Error: bad file descriptor] +3s
serialport/stream disconnected [Error: bad file descriptor] +0ms
serialport/stream #close +1ms
serialport/binding-abstract close +3s
serialport/stream _read queueing _read for after open +0ms
serialport/bindings/poller Stopping poller +2ms
serialport/bindings/poller Destroying poller +1ms
serialport/stream binding.close finished +1ms
Port closed: bad file descriptor
serialport/stream .list +1s
serialport/stream .list +1s
serialport/stream .list +1s
serialport/stream opening path: /dev/ttyUSB0 +44ms
serialport/binding-abstract open +3s
serialport/stream _read queueing _read for after open +0ms
serialport/bindings/poller Creating poller +3s
serialport/stream opened path: /dev/ttyUSB0 +2ms
serialport/stream _write 11 bytes of data +0ms
serialport/binding-abstract write 11 bytes +2ms
serialport/stream _read reading { start: 0, toRead: 65536 } +0ms
serialport/binding-abstract read +0ms
serialport/bindings/unixWrite Starting write 11 bytes offset 0 bytesToWrite 11 +6s
serialport/bindings/unixRead Starting read +6s
serialport/bindings/unixWrite write returned: wrote 11 bytes +0ms
serialport/bindings/unixWrite Finished writing 11 bytes +0ms
serialport/stream binding.write write finished +0ms
serialport/stream _write 10 bytes of data +0ms
serialport/binding-abstract write 10 bytes +0ms
Write get_serial
on /dev/ttyUSB0
serialport/bindings/unixWrite Starting write 10 bytes offset 0 bytesToWrite 10 +0ms
serialport/bindings/unixRead read error { [Error: EAGAIN: resource temporarily unavailable, read] errno: -11, code: 'EAGAIN', syscall: 'read' } +0ms
serialport/bindings/unixRead waiting for readable because of code: EAGAIN +1ms
serialport/bindings/poller Polling for "readable" +2ms
serialport/bindings/unixWrite write returned: wrote 10 bytes +1ms
serialport/bindings/unixWrite Finished writing 10 bytes +0ms
serialport/stream binding.write write finished +1ms
Write fmcw_temp
on /dev/ttyUSB0
serialport/bindings/poller received "readable" +21ms
serialport/bindings/unixRead Starting read +21ms
serialport/bindings/unixRead Finished read 71 bytes +0ms
serialport/stream binding.read finished { bytesRead: 71 } +22ms
Unknown command: get_serial
Unknown command: fmcw_temp
serialport/stream _read reading { start: 71, toRead: 65465 } +0ms
serialport/binding-abstract read +23ms
serialport/bindings/unixRead Starting read +1ms
serialport/bindings/unixRead read error { [Error: EAGAIN: resource temporarily unavailable, read] errno: -11, code: 'EAGAIN', syscall: 'read' } +0ms
serialport/bindings/unixRead waiting for readable because of code: EAGAIN +0ms
serialport/bindings/poller Polling for "readable" +1ms
So reinitialising the port after a connection loss seems to not working properly. I don't know if it's a general problem with node.js serialport, or if I am using the package incorrectly. Maybe it's something with my Linux distribution (it's openSuse 15.1 by the way).
I would be glad if someone could help me out here. Thank you.
As mentioned if you wait 4+ seconds to go on after reconnecting the device, you get the correct data means the buffer are not getting cleared or previous operation is still in progress.
It appears that the embedded device may be busy processing previous command or some intermediate buffer is not getting cleared.
Can create and read /tmp/temp.zip with AWS Lambda but this line causes an error:
var zip = new AdmZip("/tmp/temp.zip"); // https://www.npmjs.com/package/adm-zip
What does the error mean?
2018-08-08T13:23:41.074Z 2c1d866d-9b0e-11e8-8f32-8b0d6b822525 Error: EFAULT: bad address in system call argument, read
at Object.fs.readSync (fs.js:675:18)
at tryReadSync (fs.js:540:20)
at Object.fs.readFileSync (fs.js:575:19)
at new module.exports (/var/task/node_modules/adm-zip/zipFile.js:17:17)
at new module.exports (/var/task/node_modules/adm-zip/adm-zip.js:20:11)
at PassThrough.readStream.on (/var/task/index.js:28:19)
at emitNone (events.js:111:20)
at PassThrough.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
END RequestId: 2c1d866d-9b0e-11e8-8f32-8b0d6b822525
REPORT RequestId: 2c1d866d-9b0e-11e8-8f32-8b0d6b822525 Duration: 39773.72 ms Billed Duration: 39800 ms Memory Size: 128 MB Max Memory Used: 128 MB
RequestId: 2c1d866d-9b0e-11e8-8f32-8b0d6b822525 Process exited before completing request
The clue:
Memory Size: 128 MB Max Memory Used: 128 MB
So the lambda was running out of memory. Giving it 1024 MB solved the problem.
According to this guide i have successfully create JWT for Google service account using Java example and it's worked. However, these lines are still "magical" for me:
GoogleCredential credential = GoogleCredential.fromStream(resourceAsStream);
PrivateKey privateKey = credential.getServiceAccountPrivateKey();
But i can't repeat it using Node.js. Postman says "Could not get any response".
Here is my code.
const jwt = require('jsonwebtoken');
const TOKEN_DURATION_IN_SECONDS = 3600;
const issueJWT = (
issuedAt = Math.floor(Date.now() / 1000),
serviceAccount = require('path/to/service-account.json')
) =>
jwt.sign(
{
'iss': serviceAccount.client_email,
'sub': serviceAccount.client_email,
'aud': `https://${SERVICE_NAME}/${API_NAME}`,
'iat': issuedAt,
'exp': issuedAt + TOKEN_DURATION_IN_SECONDS,
},
serviceAccount.private_key,
{
algorithm: 'RS256',
header: {
'kid': serviceAccount.private_key_id,
'typ': 'JWT',
'alg': 'RS256',
},
}
);
Onlinde decoder show same header and body for tokens created using Node.js and Java.
So, i assume that signatures are different.
Via jwt from java:
curl --header "Authorization: Bearer {jwt-from-java}" https://bigtableadmin.googleapis.com/v2/projects/{project-name}/instances -v
>
* schannel: client wants to read 102400 bytes
* schannel: encdata_buffer resized 103424
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: encrypted data got 836
* schannel: encrypted data buffer: offset 836 length 103424
* schannel: decrypted data length: 773
* schannel: decrypted data added: 773
* schannel: decrypted data cached: offset 773 length 102400
* schannel: encrypted data length: 34
* schannel: encrypted data cached: offset 34 length 103424
* schannel: decrypted data length: 5
* schannel: decrypted data added: 5
* schannel: decrypted data cached: offset 778 length 102400
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: decrypted data buffer: offset 778 length 102400
* schannel: schannel_recv cleanup
* schannel: decrypted data returned 778
* schannel: decrypted data buffer: offset 0 length 102400
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
< Vary: X-Origin
< Vary: Referer
< Date: Sat, 21 Jul 2018 00:11:31 GMT
< Server: ESF
< Cache-Control: private
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Alt-Svc: quic=":443"; ma=2592000; v="44,43,39,35"
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
{
"instances": [
...
]
}
* Connection #0 to host bigtableadmin.googleapis.com left intact
Via jwt from node.js:
curl --header "Authorization: Bearer {jwt-from-node}" https://bigtableadmin.googleapis.com/v2/projects/{project-name}/instances -v
>
* schannel: client wants to read 102400 bytes
* schannel: encdata_buffer resized 103424
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: encrypted data got 836
* schannel: encrypted data buffer: offset 836 length 103424
* schannel: decrypted data length: 773
* schannel: decrypted data added: 773
* schannel: decrypted data cached: offset 773 length 102400
* schannel: encrypted data length: 34
* schannel: encrypted data cached: offset 34 length 103424
* schannel: decrypted data length: 5
* schannel: decrypted data added: 5
* schannel: decrypted data cached: offset 778 length 102400
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: decrypted data buffer: offset 778 length 102400
* schannel: schannel_recv cleanup
* schannel: decrypted data returned 778
* schannel: decrypted data buffer: offset 0 length 102400
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Bearer realm="https://accounts.google.com/"
< Vary: X-Origin
< Vary: Referer
< Content-Type: application/json; charset=UTF-8
< Date: Sat, 21 Jul 2018 00:08:58 GMT
< Server: ESF
< Cache-Control: private
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Alt-Svc: quic=":443"; ma=2592000; v="44,43,39,35"
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
* Connection #0 to host bigtableadmin.googleapis.com left intact
How can i create JWT for Google service account using Node.js?
So from the error message it looks like this is not a JWT specific issue. This Google Groups post shows that the issue is due an incorrect CURL command being used. Check the curl command syntax and access token placement to make sure it is valid.
Suddenly, now it's works without any changes in code.
Our application uses a non-blocking socket usage with connect and select operations (c code). The pusedo code is as below:
unsigned int ConnectToServer(struct sockaddr_in *pSelfAddr,struct sockaddr_in *pDestAddr)
{
int sktConnect = -1;
sktConnect = socket(AF_INET,SOCK_STREAM,0);
if(sktConnect == INVALID_SOCKET)
return -1;
fcntl(sktConnect,F_SETFL,fcntl(sktConnect,F_GETFL) | O_NONBLOCK);
if(pSelfAddr != 0)
{
if(bind(sktConnect,(const struct sockaddr*)(void *)pSelfAddr,sizeof(*pSelfAddr)) != 0)
{
closesocket(sktConnect);
return -1;
}
}
errno = 0;
int nRc = connect(sktConnect,(const struct sockaddr*)(void *)pDestAddr, sizeof(*pDestAddr));
if(nrC != -1)
{
return sktConnect;
}
if(errno != EINPROGRESS)
{
int savedError = errno;
closesocket(sktConnect);
return -1;
}
fd_set scanSet;
FD_ZERO(&scanSet);
FD_SET(sktConnect,&scanSet);
struct timeval waitTime;
waitTime.tv_sec = 2;
waitTime.tv_usec = 0;
int tmp;
tmp = select(sktConnect +1, (fd_set*)0, &scanSet, (fd_set*)0,&waitTime);
if(tmp == -1 || !FD_ISSET(sktConnect,&scanSet))
{
int savedErrorNo = errno;
writeLog("Connect %s failed after select, cause %d, error %s",inet_ntoa(pDestAddr->sin_addr),savedErrorNo,strerror(savedErrorNo));
closesocket(sktConnect);
return -1;
}
. . . . .}
There are 80 such nodes and the application connects to all its peer in round-robin fashion.
In this phase, some of the nodes are not able to connect (api – connect + select) with error number 115.
In the below logs (of tcpdump output) for success scenario, we can
see (SYN, SYN+ACK, ACK) but no entry of even SYN is present for failed
node in tcpdump logs.
The tcpdump logs are:
387937 2012-07-05 07:45:30.646514 10.18.92.173 10.137.165.136 TCP 33728 > 8441 [SYN] Seq=0 Ack=0 Win=5792 Len=0 MSS=1460 TSV=1414450402 TSER=912308224 WS=8
387947 2012-07-05 07:45:30.780762 10.137.165.136 10.18.92.173 TCP 8441 > 33728 [SYN, ACK] Seq=0 Ack=1 Win=5792 Len=0 MSS=1460 TSV=912309754 TSER=1414450402 WS=8
387948 2012-07-05 07:45:30.780773 10.18.92.173 10.137.165.136 TCP 33728 > 8441 [ACK] Seq=1 Ack=1 Win=5888 Len=0 TSV=1414450435 TSER=912309754
All the above three events indicate the success information.
387949 2012-07-05 07:45:30.782652 10.18.92.173 10.137.165.136 TCP 33728 > 8441 [PSH, ACK] Seq=1 Ack=1 Win=5888 Len=320 TSV=1414450436 TSER=912309754
387967 2012-07-05 07:45:30.915615 10.137.165.136 10.18.92.173 TCP 8441 > 33728 [ACK] Seq=1 Ack=321 Win=6912 Len=0 TSV=912309788 TSER=1414450436
388011 2012-07-05 07:45:31.362712 10.18.92.173 10.137.165.136 TCP 33728 > 8441 [PSH, ACK] Seq=321 Ack=1 Win=5888 Len=320 TSV=1414450581 TSER=912309788
388055 2012-07-05 07:45:31.495558 10.137.165.136 10.18.92.173 TCP 8441 > 33728 [ACK] Seq=1 Ack=641 Win=7936 Len=0 TSV=912309933 TSER=1414450581
388080 2012-07-05 07:45:31.702336 10.137.165.136 10.18.92.173 TCP 8441 > 33728 [PSH, ACK] Seq=1 Ack=641 Win=7936 Len=712 TSV=912309985 TSER=1414450581
388081 2012-07-05 07:45:31.702350 10.18.92.173 10.137.165.136 TCP 33728 > 8441 [ACK] Seq=641 Ack=713 Win=7424 Len=0 TSV=1414450666 TSER=912309985
388142 2012-07-05 07:45:32.185612 10.137.165.136 10.18.92.173 TCP 8441 > 33728 [PSH, ACK] Seq=713 Ack=641 Win=7936 Len=320 TSV=912310106 TSER=1414450666
388143 2012-07-05 07:45:32.185629 10.18.92.173 10.137.165.136 TCP 33728 > 8441 [ACK] Seq=641 Ack=1033 Win=8704 Len=0 TSV=1414450786 TSER=912310106
388169 2012-07-05 07:45:32.362622 10.18.92.173 10.137.165.136 TCP 33728 > 8441 [PSH, ACK] Seq=641 Ack=1033 Win=8704 Len=320 TSV=1414450831 TSER=912310106
388212 2012-07-05 07:45:32.494833 10.137.165.136 10.18.92.173 TCP 8441 > 33728 [ACK] Seq=1033 Ack=961 Win=9216 Len=0 TSV=912310183 TSER=1414450831
388219 2012-07-05 07:45:32.501613 10.137.165.136 10.18.92.173 TCP 8441 > 33728 [PSH, ACK] Seq=1033 Ack=961 Win=9216 Len=356 TSV=912310185 TSER=1414450831
388220 2012-07-05 07:45:32.501624 10.18.92.173 10.137.165.136 TCP 33728 > 8441 [ACK] Seq=961 Ack=1389 Win=10240 Len=0 TSV=1414450865 TSER=912310185
Application Logs informing error on connect (i.e api - connect + select)
[5258: 2012-07-05 07:45:30]Connect [10.137.165.136 <- 10.18.92.173] success.
[5258: 2012-07-05 07:45:32]Connect 10.137.165.137 fail after select, cause:115, error Operation now in progress. Check whether remote machine exist and the network is normal or not.
[5258: 2012-07-05 07:45:32]Connect to server([10.137.165.137 <- 10.18.92.173], port=8441) Failed!
Success logs corresponding to first 3 entries of tcpdump. And failure log where there are no events in the tcpdump
My question is : When client initiates “connect” api for failed case,
i am not able to see any event in the tcpdump at client side (even
initial SYN). What can be the reason of this randomness.
You have hit EINPROGRESS. From the connect man page:
The socket is nonblocking and the connection cannot be completed immediately. It is possible to select(2) or poll(2) for completion by selecting the socket for writing. After select(2) indicates writability, use getsockopt(2) to read the SO_ERROR option at level SOL_SOCKET to determine whether connect() completed successfully (SO_ERROR is zero) or unsuccessfully (SO_ERROR is one of the usual error codes listed here, explaining the reason for the failure).
This is saying that EINPROGRESS is an indicator that the kernel is not able to complete the connection now, even though there are available local ports and routing cache entries. It seems this occurs when the socket state has not transitioned to "ESTABLISHED" yet. Just wait on the socket in select again, but call getsockopt afterwards to see if your connect had completed.
As to why, the socket transitions to SYN_SENT state during connect, but the packet may still be in the output queue and has not actually made it to the network device buffer yet.
After select() returns, you are not actually fetching the current status of the socket - you are seeing a stale value in errno (left over from the connect() call). Most likely your select() is simply returning after the timeout.
You need to call getsockopt(sktConnect, SOL_SOCKET, SO_ERROR, &err, ...) to get the actual status of the socket after select() returns.