AWS.SQS.receive_message => bad character error
Closed this issue · 4 comments
Good lib! Thanks for that.
I've got a problem and am wondering how to go about debugging it (for all I know this could be on AWS' side).
def client() do
AWS.Client.create(@access_key_id, @secret_access_key, @region)
end
def receive_message(queue_url \\ @queue_url) do
client()
|> AWS.SQS.receive_message(%{"QueueUrl" => queue_url}, %{})
end
Calling AwsUtils.Worker.receive_message()
works most times but, from time to time, I get this error:
12:16:31.250 [error] 3432- fatal: {:error, {:wfc_Legal_Character, {:error, {:bad_character, 339}}}}
▶▶▶
** (exit) {:fatal, {{:error, {:wfc_Legal_Character, {:error, {:bad_character, 339}}}}, {:file, :file_name_unknown}, {:line, 1}, {:col, 13520}}}
(xmerl 1.3.28) xmerl_scan.erl:4127: :xmerl_scan.fatal/2
(xmerl 1.3.28) xmerl_scan.erl:2721: :xmerl_scan.scan_char_data/5
(xmerl 1.3.28) xmerl_scan.erl:2633: :xmerl_scan.scan_content/11
(xmerl 1.3.28) xmerl_scan.erl:2136: :xmerl_scan.scan_element/12
(xmerl 1.3.28) xmerl_scan.erl:2608: :xmerl_scan.scan_content/11
(xmerl 1.3.28) xmerl_scan.erl:2136: :xmerl_scan.scan_element/12
(xmerl 1.3.28) xmerl_scan.erl:2608: :xmerl_scan.scan_content/11
(xmerl 1.3.28) xmerl_scan.erl:2136: :xmerl_scan.scan_element/12
Has anyone ever seen this?
Thanks!
@gamecubate this looks like a char that is not recognize by xmerl
, the XML parser from Erlang that is used underneath aws-elixir
. Maybe we need some "scapping" or conversion of UTF8 elements.
Do you have an example of the message that triggers the error that you can share?
@gamecubate nevermind. I managed to reproduce and fix the problem. Please try with version v0.9.2
. Let me know if this works for you :)
@philss Sure thing. Here is the body of a successfully received message:
{
"timeTaken": 0.0371146,
"content-length": "9870",
"payloadType": "stats",
"recordCount": 32,
"fromRatchet": true,
"endpointURI": "http://api.stats.com/v1/stats/hockey/nhl/teams/?languageId=6&accept=json&season=2021",
"endTimestamp": "2021-10-27T16:35:16.2223656Z",
"startTimestamp": "2021-10-27T16:35:16.185251Z",
"status": "OK",
"apiResults": [
{
"sportId": 3,
"name": "Hockey",
"league": {
"leagueId": 18,
"name": "National Hockey League",
"abbreviation": "NHL",
"displayName": "National Hockey League",
"season": {
"season": 2021,
"name": "2021-22 NHL Season",
"isActive": true,
"conferences": [
{
"conferenceId": 1,
"name": "Eastern Conference",
"abbreviation": "Eastern",
"divisions": [
{
"divisionId": 7,
"name": "Metropolitan Division",
"abbreviation": "Metropolitan",
"teams": [
{
"venue": {
"venueId": 9415,
"name": "PPG Paints Arena",
"city": "Pittsburgh",
"state": {
"stateId": 38,
"name": "Pennsylvania",
"abbreviation": "PA"
},
"country": {
"countryId": 1,
"name": "États-Unis",
"abbreviation": "USA"
}
},
"teamId": 4969,
"location": "Pittsburgh",
"nickname": "Penguins",
"abbreviation": "Pit"
},
{
"venue": {
"venueId": 18,
"name": "Madison Square Garden",
"city": "New York",
"state": {
"stateId": 32,
"name": "New York",
"abbreviation": "NY"
},
"country": {
"countryId": 1,
"name": "États-Unis",
"abbreviation": "USA"
}
},
"teamId": 4966,
"location": "New York",
"nickname": "Rangers",
"abbreviation": "NYR"
},
{
"venue": {
"venueId": 3259,
"name": "Nationwide Arena",
"city": "Columbus",
"state": {
"stateId": 35,
"name": "Ohio",
"abbreviation": "OH"
},
"country": {
"countryId": 1,
"name": "États-Unis",
"abbreviation": "USA"
}
},
"teamId": 4982,
"location": "Columbus",
"nickname": "Blue Jackets",
"abbreviation": "Cls"
}
]
},
{
"divisionId": 2,
"name": "Atlantic Division",
"abbreviation": "Atlantic",
"teams": [
{
"venue": {
"venueId": 28,
"name": "Scotiabank Arena",
"city": "Toronto",
"state": {
"stateId": 60,
"name": "Ontario",
"abbreviation": "ON"
},
"country": {
"countryId": 2,
"name": "Canada",
"abbreviation": "CAN"
}
},
"teamId": 4974,
"location": "Toronto",
"nickname": "Maple Leafs",
"abbreviation": "Tor"
},
{
"venue": {
"venueId": 3257,
"name": "FLA Live Arena",
"city": "Sunrise",
"state": {
"stateId": 9,
"name": "Florida",
"abbreviation": "FL"
},
"country": {
"countryId": 1,
"name": "États-Unis",
"abbreviation": "USA"
}
},
"teamId": 4979,
"location": "Florida",
"nickname": "Panthers",
"abbreviation": "Fla"
},
{
"venue": {
"venueId": 3253,
"name": "Amalie Arena",
"city": "Tampa",
"state": {
"stateId": 9,
"name": "Florida",
"abbreviation": "FL"
},
"country": {
"countryId": 1,
"name": "États-Unis",
"abbreviation": "USA"
}
},
"teamId": 4973,
"location": "Tampa Bay",
"nickname": "Lightning",
"abbreviation": "TB"
}
]
}
]
},
{
"conferenceId": 2,
"name": "Western Conference",
"abbreviation": "Western",
"divisions": [
{
"divisionId": 3,
"name": "Central Division",
"abbreviation": "Central",
"teams": [
{
"venue": {
"venueId": 4,
"name": "United Center",
"city": "Chicago",
"state": {
"stateId": 13,
"name": "Illinois",
"abbreviation": "IL"
},
"country": {
"countryId": 1,
"name": "États-Unis",
"abbreviation": "USA"
}
},
"teamId": 4957,
"location": "Chicago",
"nickname": "Blackhawks",
"abbreviation": "Chi"
},
{
"venue": {
"venueId": 4600,
"name": "Canada Life Centre",
"city": "Winnipeg",
"state": {
"stateId": 55,
"name": "Manitoba",
"abbreviation": "MB"
},
"country": {
"countryId": 2,
"name": "Canada",
"abbreviation": "CAN"
}
},
"teamId": 4981,
"location": "Winnipeg",
"nickname": "Jets",
"abbreviation": "Wpg"
}
]
},
{
"divisionId": 4,
"name": "Pacific Division",
"abbreviation": "Pacific",
"teams": [
{
"venue": {
"venueId": 25,
"name": "Climate Pledge Arena",
"city": "Seattle",
"state": {
"stateId": 47,
"name": "Washington",
"abbreviation": "WA"
},
"country": {
"countryId": 1,
"name": "États-Unis",
"abbreviation": "USA"
}
},
"teamId": 41971,
"location": "Seattle",
"nickname": "Kraken",
"abbreviation": "Sea"
},
{
"venue": {
"venueId": 3229,
"name": "Scotiabank Saddledome",
"city": "Calgary",
"state": {
"stateId": 52,
"name": "Alberta",
"abbreviation": "AB"
},
"country": {
"countryId": 2,
"name": "Canada",
"abbreviation": "CAN"
}
},
"teamId": 4956,
"location": "Calgary",
"nickname": "Flames",
"abbreviation": "Cgy"
},
{
"venue": {
"venueId": 15339,
"name": "T-Mobile Arena",
"city": "Las Vegas",
"state": {
"stateId": 28,
"name": "Nevada",
"abbreviation": "NV"
},
"country": {
"countryId": 1,
"name": "États-Unis",
"abbreviation": "USA"
}
},
"teamId": 33447,
"location": "Vegas",
"nickname": "Golden Knights",
"abbreviation": "VGK"
}
]
}
]
}
]
}
}
}
]
}
Holy smokes. You did it, and faster than your shadow. :) Works perfectly. Thanks a bunch.