Using #azure/event-hubs sending message always run into a timeout - javascript

I am trying to send a message to the configured eventhub for implicit grand flow.
I try to get the following example to run for sending to event hub. I get to the point when the user/client needs allow the azure application. But after then when I am using the created producer - I get a timeout after 2 minutes. (The request with message_id "xxx" to "$cbs" endpoint timed out. Please try again later.)
What can causes this type of error? When I am producing messages in .net everything is working fine. And if its because of auth issue (because of the complex configuration) I would get an other error (like I got before I set it up correctly)
Some other infos:
I gave the app registration only "Azure Event Hubs Data Send" role and I put the role to the app twice one time on the subscription level and one directly in the event hub (IAM). Can this double role cause an error - no or?

Related

Jumping over to another intent by using the 'agent.setFollowupEvent(targetIntentEventName)' method in the DialogFlow Messenger fulfillment

I'm trying to find a solution to launch another DialogFlow Intent (via its event) from a webhook (node.js) server after collecting users email address and checking their registration status by making a POST API call to a remote organization server.
Here's a basic schema:
User: Hello!
Chatbot: Hello, I'm an assistance bot. Can I have your email address to verify your registration status, please?
User: funnyname#email.com
Chatbot: Thank you, let me check your status ...
---> Fulfilment code makes a POST API call and gets users status back from a server if there's a match.
Here based on the users status I want to launch a new intent: either Registered_Users_Intent or New_Users_Intent. I tried to use the agent.setFollowupEvent(({ "name": "targetIntentEventName" }) method, but it doesn't trigger a desired event[intent] all the time. I'm not sure how to set it up properly in the fulfilment code to make it work all the time.
Would anyone have any suggestions or reference materials to make this set-up work, please?
When you make a webhook fulfillment request, your API should respond with a JSON response that Dialogflow understands. Instead of calling dialogflow APIs to trigger an event from within your webhook API, the JSON response of the API can contain the name of the event to be triggered next and Dialogflow will do the rest.
Here's the reference for the fulfillment response to trigger a follow-up event: https://cloud.google.com/dialogflow/es/docs/fulfillment-webhook#event
Also, the most likely reason that your current approach works sometimes and doesn't the others, is because triggering an event using dialogflowv2 APIs AND sending back a JSON response (which probably doesn't have the name of the follow up event mentioned) creates a race condition.
Since you are using the Dialogflow Fulfillment Library, make sure to use the latest version in your package.json file. Also, when using the agent.setFollowupEvent() method, make sure to include an agent.add() method for the response. This response will not be returned but is a requirement to be able to use the agent.setFollowupEvent() method.
Here’s an example:
function nameOfFunction(agent) {
agent.add(`sample response`);
agent.setFollowupEvent('event_name');
}
For more information on Dialogflow Fulfillment Library, see here. Note that this library is not maintained.
Otherwise, you may create your own code and host it on your chosen web server. From there, you can invoke events by setting the followupEventInput field of the WebhookResponse. Check here for more information.

Spring controller is getting called twice at test environment

I have been facing an issue with spring controller for a long time. Even after a lot of research over this spring controller redirection issues that didn't give any solution.
Issue: We are doing some payment integrations such as Sofort, AliPay and PayPal using Spring. Everything working fine in local machine(PC desktop) whereas it causes the issue with PayPal at test enviroments(Cloud deployment servers);however, remaining all other payment types are working fine.
There is the PayPal response handler url(Controller) at merchant server where it handles the paypal payment response, the handler url is getting called twice. Therefore, its not giving appriopriate results as it should get called only once.
PayPal Response Handler URL:
us/en-us/checkout/payment/paypal/handleResponse?token=EC-XXXXXXXXXXXX&PayerID=XXXXXX
Observations:
a) Whenever we have such kind of issues that is url getting called twice. At network tab of chrome, JS could be the issue. But, we haven't found such kind of history at there.
b) We use load balancer at our test environments. At sometimes, load balancer would make the url to get called twice. But, we didn't find a such kind of calls at loadbalancer.
c) Spring Handler method as below.
#RequestMapping(path = "/handleResponse", method = RequestMethod.GET)
public String handleResponse(#RequestParam(name = "token")
final String token, #RequestParam(name = "PayerID")
final String payerId)
d) There is no issue with PayPal configurations or PayPal servers. If I would hit the browser with the sample url below it is getting called twice, eventhough its not sending from PayPal. Hence, there is no issue with PayPal.
https://ABCDMERCHANT.com/us/en-us/checkout/payment/paypal/handleResponse?token=EC-XXXXXXXXXXX&PayerID=XXXXXXXXXXX
Guys, If could you give any suggestions to trace it down the root cause of it. that will be helpful for me.
Thanks InAdvance!!
We had given fixes to handle the second call however, during further tests even still it was failed and found the root cause and given the fix.
Root Cause: PayPal test environment, takes more than 45 seconds to complete set, get, authorize/capture and place order requests but the Application server time out is 10 seconds there its failed hence it makes second call.
Fix: we have increased the server time out to 50 seconds and its stopped making second request.

Slack OAuth Setup Step 1 - Testing w/ Postman - Error: Invalid client_id parameter

I'm in the process of setting up oauth following the process laid out by Slack for my Slack app (I've used a token previously for the same app). Unfortunately I'm hitting a snag with step 1. I'm using Postman to test out the GET request to https://slack.com/oauth/authorize by passing along 3 parameters (client_id, scope, & redirect_uri) expecting something that gets me closer to receiving a code (step 2). But what I receive is an error message of Invalid client_id parameter. I've checked my client_id in Postman against what's provided by Slack multiple times but can't figure out where this issue is stemming from. What am I doing wrong?
Additionally I'm thinking of using Passport with the Passport-Slack strategy for authentication.
The reason this does not work is that you have defined the properties in the header, but you need to provide those as GET parameters.
To fix remove them from the header and either add them to the URL (e.g. ?client_id=xxx&scope=xxx) or click on Params next to the Send button to enter them directly.

How to send chat messages using converse library

I am using openfire as an XMPP server and using converse as client library. I want to send a chat message from my chat window to openfire. For this I want to send the text to a converse method which will send the message to the XMPP server.
I am trying to send the message using the following:
var msg = converse.env.$msg({
from: 'a1#localhost',
to: 'a6#localhost',
type: 'chat',
body: "Hi"
});
converse.send(msg);
But this sends the following frame in network of console in websocket:
message from='a1#localhost' to='a6#localhost' type='chat' body='Hi' xmlns='jabber:client'/>
This does not transfer message to the other user neither it stores it in the table. I am pretty much sure I am calling a wrong function. Can anyone povide any help.
You are calling the right function.
What you'll probably miss:
Listener of messages in "a6#localhost" client: as I read in documentation there are few functions
Probably, the right name of server. "localhost" has problem. You can
check Openfire for real service name on his own web panel
To check if a message it's delivered in Openfire you'll can check
OF's log (check debug one, but probably you'll have to enable it).
Real time messages are not stored on database, only groupchat's ones
and not everytime AND offline messages. To not find them on db means nothing
https://conversejs.org/docs/html/development.html
converse.chats.open('buddy#example.com');
converse.chats.get('buddy#example.com');
converse.listen.on('message', function (event, messageXML) { ... });
The syntax is wrong. conversejs uses strophe plugin to construct and send messages. It exposes the strophe $msg message builder for constructing stanzas. It has to be in the following format:
converse.env.$msg({from: 'a1#localhost', to: 'a6#localhost', type: 'chat'}).c('body').t('Hi');
You need to add a body node and within it a text node for the message.
You can also create and add your own api method and internally create a method that sends your custom stanza, and expose it using the api.

How do I send a channel message using channel.trigger with websocket-rails gem

I'm building a simple real-time chat app to learn how to use websockets with RoR and I don't think I'm understanding how channels work because they're not doing what I expect. I can successfully send a message to my Rails app using the dispatcher.trigger() method, and use my websocket controller to broadcast a message to all clients that subscribe to the channel. That all works fine. What does NOT work is using a channel (via the channel.trigger() method) to send a message to other clients. The websocket-rails wiki says...
Channel events currently happen outside of the Event Router flow. They
are meant for broadcasting events to a group of connected clients
simultaneously. If you wish to handle events with actions on the
server, trigger the event on the main dispatcher and specify which
controller action should handle it using the Event Router.
If I understand this correctly, I should be able to user the channel.trigger() method to broadcast a message to clients connected to the channel, without the message being routed through my RoR app, but it should still reach the other connected clients. So here's my code...
var dispatcher = new WebSocketRails('localhost:3000/websocket');
var channel = dispatcher.subscribe('channel_name');
channel.bind('channel_message', function(data) {
alert(data.message);
});
$("#send_message_button").click(function() {
obj = {message: "test"};
channel.trigger('channel_message', obj);
});
With the code listed above, I would expect that when I click the button, it sends a channel message using channel.trigger() and the channel_message binding should be executed on all clients, displaying an alert that reads "test". That doesn't happen. I'm using Chrome tools to inspect the websocket traffic and it shows the message being sent...
["channel_message",{"id":113458,"channel":'channel_name',"data":{"message":"test"},"token":"96fd4f51-6321-4309-941f-38110635f86f"}]
...but no message is received. My questions are...
Am I misunderstanding how channel-based websockets work with the websocket-rails gem?
If not, what am I doing wrong?
Thanks in advance for all your wisdom!
I was able to reproduce a working copy based on an off-the-shelf solution from the wiki along with your very own code.
I've packaged the whole thing here. The files you might be interested are home_controller.rb, application.js and home/index.html.erb.
It seems your understanding of channel-based websockets is correct. About the code, make sure to load the websocket javascript files and to enclose your code inside a document.ready. I had the exact same problem you're having without the latter.
//= require websocket_rails/main
$(function() {
// your code here...
});
Let me know if it works. Best Luck!

Categories

Resources