Monday, October 19, 2020

Lex chatbot is not rendering html on web page

If you have integrated Lex chatbot in your website and it is showing html as a response message, it means your javascript is not able to render the html on the web page.

You need to handle this issue at the client side as it is correct method to send html as a response message from Lex.

If you are using default javascript code which you found in AWS blog for your Lex chatbot integration, you need to modify it little.

Find the following code in javascript function showResponse(lexResponse)

and replace following piece of code

	    if (lexResponse.message) {
	responsePara.appendChild(document.createTextNode(lexResponse.message));
	responsePara.appendChild(document.createElement('br'));
    }

with

    	if (lexResponse.message) {

        var message = lexResponse.message.replace(/"/g, '\'');
        responsePara.innerHTML = message;
        responsePara.appendChild(document.createElement('br'));
    }

Now you can add html markups in the message section of Lex chatbot so it will return this message when the 'Utterance' will be matched and It will render the html on the web page.

jenkins error - Failed to connect to repository : Command 'git ls-remote -h'

If you are adding a repository in 'Source Code Management' section of Jenkins and after adding correct username and password as a credentials, it is still showing 'Failed to connect to repository' error then this solution might work for you.

Solution :

check the character '@' in your username and password. I would suggest you to not use email as your git username. To remember username, people use complete email as a username. If your email is john.doe@mail.com, I would suggest you to not use 'john.doe@mail.com' as a username. You can use john.doe or if it is not available, you can use any number after it.

Similarly you should not use '@' in the password too.

After replacing '@' with other special character like '_', you should try to connect git repository from Jenkins again.


Sunday, September 13, 2020

ftp connection error on command line

500 I won't open a connection to 172.31.xx.xxx (only to 19.216.xxx.xxx)ftp: bind: Address already in use

If you are trying to make a connection to ftp on command line and you are getting above error, it means ftp is trying to connect to the server using private IP but it cannot connect to remote server using private IP as it needs public IP. You have already passed public IP but still it is connecting to private IP and showing error 500. Here is solution for you.

Soluton :

Connect to ftp server in passive mode using -p

ftp -p ftp.domainname
or
ftp -p 19.216.xxx.xxx
It will ask username and password and after typing it, you should be able to connect to remote server successfully.