question

jonas.barnaby@gmail.com avatar image
jonas.barnaby@gmail.com asked

Uploading a server build via Java API

Hi everybody,

I'm trying to write an app in Java to automate our server build upload process. As of now I'm able to get the GetServerBuildUploadUrl url but I don't know how to properly upload our zip once I got it. I've been reading the Amazon documentation on the subject and, as far as I've seen, the uploading is done via an OutputStreamWriter (here: http://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObjectJavaSDK.html). Should I use something like the UploadObject() method shown in the documentation to serialize and upload the file? Or perhaps there's another way to upload the build other than using the AWS SDK?

Thanks!

10 |1200

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

jonas.barnaby@gmail.com avatar image
jonas.barnaby@gmail.com answered

Hi, Brendan.

I'm not receiving any error message, the upload process ends succesfully. The result status I get from the API call, however, says "Validating", which is the same message I get if I upload the build via the Game Manager.

10 |1200

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

brendan avatar image
brendan answered

All builds, once uploaded, go to the Validating state while the service checks that they're good builds (executable is there, no problems we can detect). Depending on the total size of the Zip, it may take a couple of minutes to finish this stage, but it should shortly. If you're not seeing that, are you using a different build from the one I downloaded from your title for testing? Can you send me a secure download link (use devrel@playfab.com)?

One thing that can't cause a problem validating the build, but which you will need to correct, is that from your post, you're setting MaxGamesPerHost (the number indicating how many instances of this game build can run on a game server host box in AWS) to 1 and MinFreeSlots (the number of slots available to spin up an instance of the game that must be available at all times) to 10. That means you can only run one session on the AWS server, and that you always want to have 10 of them available for new players. I suspect that you meant to have these the other way around.

10 |1200

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

contact-3 avatar image
contact-3 answered

Hello, getting same issue validating build when uploading from a powershell script using Visual Team Services.

Here is the ps1 script we use :

Write-Host $env:BUILD_BUILDNUMBER


Write-Host $env:PLAYFABSECRETKEY


Write-Host $env:PLAYFABGAMEID


#Build id
#$buildId = $env:BUILD_BUILDNUMBER
$buildId = "main_build"


#list server builds
$url = "https://$env:PLAYFABGAMEID.playfabapi.com/Admin/ListServerBuilds"


$result = Invoke-RestMethod -Uri $url -Method Post -Headers @{
	"Content-Type" = "application/json"
	"X-SecretKey" = "$env:PLAYFABSECRETKEY"
}


#Remove first server build
$url = "https://$env:PLAYFABGAMEID.playfabapi.com/Admin/RemoveServerBuild"


$ServerBuildToRemove = $result.data.Builds[0].BuildId


$json = @"
{ "BuildId": "$ServerBuildToRemove" }
"@


Write-Host $json


$result = Invoke-RestMethod -Uri $url -Method Post -Headers @{
	"Content-Type" = "application/json"
	"X-SecretKey" = "$env:PLAYFABSECRETKEY"
} -Body $json


Write-Host $result
Write-Host $result.data


#Get new upload url
$url = "https://$env:PLAYFABGAMEID.playfabapi.com/Admin/GetServerBuildUploadUrl"


$json = @"
{ "BuildId": "$buildId" }
"@


Write-Host $json


$result = Invoke-RestMethod -Uri $url -Method Post -Headers @{
	"Content-Type" = "application/json"
	"X-SecretKey" = "$env:PLAYFABSECRETKEY"
} -Body $json


Write-Host $result
Write-Host $result.data


#Upload Build
$wc = new-object System.Net.WebClient
$build = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/$env:BUILD_BUILDNUMBER.zip"


Write-Host $build


$result = Invoke-WebRequest -UseBasicParsing -Uri $result.data.URL -Method Put -Headers @{
	"Content-Type" = "application/x-zip-compressed"
} -InFile $build


Write-Host $result
Write-Host $result.data


#Set Build Options
$url = "https://$env:PLAYFABGAMEID.playfabapi.com/Admin/AddServerBuild"
$json = @"
{
  "BuildId": "$buildId",
  "ExecutablePath": "Morphiks.Anima.Server.exe",
  "ActiveRegions": [
    "EUWest"
  ],
  "Comment": "",
  "MaxGamesPerHost": 100,
  "MinFreeGameSlots": 30
}
"@


$result = Invoke-RestMethod -Uri $url -Method Post -Headers @{
	"Content-Type" = "application/json"
	"X-SecretKey" = "$env:PLAYFABSECRETKEY"
} -Body $json


Write-Host $result
Write-Host $result.data


Log For last request

2016-11-19T13:59:46.4366457Z @{code=200; status=OK; data=}
2016-11-19T13:59:46.4376489Z @{BuildId=main_build; ActiveRegions=System.Object[]; MaxGamesPerHost=100; MinFreeGameSlots=30; Comment=; Timestamp=2016-11-19T13:59:46.896Z; TitleId=BAC6; Status=Validating}


10 |1200

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

brendan avatar image
brendan answered

The original problem for the thread was actually that they were having trouble uploading the build at all. If you're getting to the Validating stage, your file was uploaded successfully. The validation that then occurs is the same, no matter how you uploaded the file. If you're failing validation, then there's something wrong with the package that was uploaded. What Title ID is this for, and what is the name of the build file you uploaded?

1 comment
10 |1200

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

contact-3 avatar image contact-3 commented ·

It was an issue in the CI zip packaging, fixing the packaging did the trick, so the above code is indeed working. It was kinda the same issue then

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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