Announcement: The Alexa Skills Community Is Moving To Stack Overflow

For improved usability and experience, Alexa skills related forum support will be transitioned to Stack Overflow. Effective January 10, 2024, the Amazon Developer Forums will no longer be available. For continued Alexa skills support you can reach out to us on Stack Overflow or via Contact Us.


zero-z77 avatar image
zero-z77 asked

Need Help, Alexa keeps breaking my connection

Ok, so i'm attempting to host a skill at my own endpoint, i'm writing the code in C/C++. Starting out i'm trying to do a sort of "hello world" to get things started. The problem i have run into, is that as soon as all the TLS handshaking is done alexa immediately, for no apparent reason, terminates the connection before i can send or recieve any http requests. i'll list all pertinent information now. Wireshark trace (i did not include ip's for security reasons) Source Dest Protocol length info Alexa Server TLSv1 260 Client Hello Server Alexa TLSv1 1086 Server Hello, Certificate, Server Hello Done Alexa Server TLSv1 333 Client Key Exchange Alexa Server TLSv1 72 Change Cipher Spec Alexa Server TLSv1 111 Encrypted Handshake Message Server Alexa TLSv1 117 Change Cypher Spec, Encrypted Handshake Message Alexa Server TLSv1 95 Encrypted Alert <--- Alexa Terminates Connection Hardware Connection Map (i do have HTTPS port forwarding set up on my router) WWW<-----Cable(Coax)----->Modem<-----Ethernet----->Router<-----Ethernet----->Server System Specs OS: Windows 10 x64 SHELL: MSYS(Under MinGW Installation) RAM: 8GB DDR3 1333 CPU: AMD FX 6300 X6 @ 3.5 GHz LIBRARIES: openssl (Under MSYS) COMPILER: GNU g++ (Under MSYS) Compiler invocation g++ socktest.cpp -lssl -lcrypto Source Code(socktest.cpp) #include #include #include #include #include #include #include #include #include #include #define MAXBUF 8000 // Maximum buffer size using namespace std; // Creates a listner on the given port. int listner(int port){ struct sockaddr_in addr; int sock; sock = socket(PF_INET,SOCK_STREAM, 0); // make socket memset(&addr,0,sizeof(addr)); // setup address addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = INADDR_ANY; if(bind(sock,(sockaddr*)&addr,sizeof(addr))!=0){ // bind socket perror("Binding Failed\n"); abort(); } if(listen(sock,10)!=0){ // start listening perror("failed to listen\n"); abort(); } return sock; } // initializes a new SSL context SSL_CTX* makeContext(){ const SSL_METHOD *method; SSL_CTX *ctx; OpenSSL_add_all_algorithms(); // load everything OpenSSL_add_ssl_algorithms(); SSL_library_init(); SSL_load_error_strings(); method = TLSv1_server_method(); // use TLSv1 ctx = SSL_CTX_new(method); if(ctx==NULL){ ERR_print_errors_fp(stderr); abort(); } return ctx; } // loads key and certificate from file void loadCerts(SSL_CTX* ctx, char* CertFile, char* KeyFile){ if(SSL_CTX_use_certificate_file(ctx, CertFile, SSL_FILETYPE_PEM) <= 0){ ERR_print_errors_fp(stderr); abort(); } if(SSL_CTX_use_PrivateKey_file(ctx, KeyFile, SSL_FILETYPE_PEM) <=0){ ERR_print_errors_fp(stderr); abort(); } if(!SSL_CTX_check_private_key(ctx)){ fprintf(stderr, "Failed to validate key\n"); abort(); } } // handler for client requests void handleClient(SSL* ssl){ char buf[MAXBUF]; int sock; int s; // reply text const char* reply = "HTTP/1.1 200 OK\nContent-Type: application/json;charset=UTF-8\nContent-Length:0"; if(SSL_accept(ssl)<0){ ERR_print_errors_fp(stderr); abort(); } else{ s = SSL_read(ssl, buf, sizeof(buf)); // read from connection if(s>0){ buf[s] = '\0'; printf(buf); printf("canary\n"); // used for debugging SSL_write(ssl,reply,strlen(reply)); // send reply } else{ ERR_print_errors_fp(stderr); } } sock = SSL_get_fd(ssl); // clean up SSL_free(ssl); close(sock); } // main function int main(){ SSL_CTX *ctx; int port = 443; int server; ctx = makeContext(); // make SSL context loadCerts(ctx,"certificate.pem","private-key.pem"); // Load certs server = listner(port); // setup listener while(1){ struct sockaddr_in addr; // setup address int len = sizeof(addr); SSL* ssl; int client = accept(server,(sockaddr*)&addr,&len); // accept connection printf("Connection established\n"); ssl = SSL_new(ctx); // initialize a new SSL session SSL_set_fd(ssl,client); handleClient(ssl); // handle client } close(server); // clean up SSL_CTX_free(ctx); }
alexa skills kitsubmission testing certification
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Levon@Amazon avatar image
Levon@Amazon answered
Hi zero_z77, Welcome to dev forums and thanks for posting! We are going to need more info on this. If you could please provide your VendorId, the ApplicationId, and the times that you were seeing those errors (exact times with time zone), we could then try hitting your endpoints from our side and investigate this issue further. Please use the Contact Us link in your Distribution Portal account: and along with that info paste this forum thread's URL in your message. Thanks!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.