Solved: for some reason, one of my accounts wasn't logged in properly to visual studio. So publishing still occurred, but something wasn't updating properly. Relogging the account fixed everything.
Cannot get Azure function WebPubSubTrigger to fire with custom events
I have been trying to get a simple function for fire for 3 days now. I am using WebPubSub for messaging in my game (Unity). I can connect using the json.webpubsub.azure.v1 protocol and WebSocketSharp. I can join/leave group and send messages to groups no problems directly from the client using the protocol. I can also use timer triggers and they are fine, But when I try to send a custom event, I get back {"type":"ack","ackId":1,"success":false,"error":{"name":"InternalServerError","message":"Internal server error"}}. I don't see any feedback in the logstream, so I'm kinda lost. Any help would be much appreciated.
Here is how I'm setting up the handlers (per the many examples), I've also tried setting the handler to just one specific event:
https://functionsapp.azurewebsites.net/runtime/webhooks/webpubsub?code=*****************************
Here is the send normal message code that works fine:
public void SendMessageToGroup(string groupToMessage, string messageToSend)
{
if (groupToMessage == null) return;
string message = JsonConvert.SerializeObject(new
{
type = AzurePubSubKeys.SendToGroup,
group = groupToMessage,
ackId = ++this.ackId,
dataType = AzurePubSubKeys.DataText,
data = messageToSend + System.Environment.NewLine
});
webSocket.SendAsync(message, isSuccess => { Debug.Log($"[{GetType().Name}] Message Send Success: {isSuccess}"); });
}
Here is the code that gets the error:
string message = JsonConvert.SerializeObject(new
{
type = "event",
@event = "testtrigger",
ackId = ++this.ackId,
dataType = AzurePubSubKeys.DataText,
data = "this is data for the testtrigger event handler"
});
webSocket.SendAsync(message, isSuccess => { Debug.Log($"[{GetType().Name}] testtrigger Send Success: {isSuccess}"); });
Here are the functions I've been trying to get working:
[FunctionName("WebPubSubTriggerFunction")]
public static void Run(
ILogger logger,
[WebPubSubTrigger("hub", WebPubSubEventType.User, "testtrigger")] UserEventRequest request,
string data,
WebPubSubDataType dataType)
{
logger.LogInformation($"Request from: {request.ConnectionContext.UserId}, data: {data}, dataType: {dataType}");
}
[FunctionName("TestEventHandler")]
public static void TestEventHandler(
[WebPubSubTrigger(AzurePubSubNames.DefaultHub, WebPubSubEventType.User, "testevent")] WebPubSubConnectionContext context,
string data,
ILogger log)
{
log.LogDebug($"[TestEventHandler] *********************** start ***********************\n{context.UserId}\n{data}");
}