0
votes

I have done everything precisely as I think I should. My application works if I run it on the cloud. The commands I run: gcloud builds submit --tag gcr.io/****
gcloud run deploy *** --region us-central1 --platform managed --image gcr.io/t*** --allow-unauthenticated --port=26951

Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk

COPY . /app

WORKDIR /app

RUN dotnet publish -c Release -o out

ENTRYPOINT ["dotnet", "Test.dll"]

Program:

using System;
using System.IO;
using System.Net;
using System.Net.Sockets;


namespace Server
{
    class Program
    {
        private static TcpListener tcpListener;
        public static void Main(string[] args)
        {
            
            tcpListener = new TcpListener(IPAddress.Any, 26951);
   
            tcpListener.Start();
         
            tcpListener.BeginAcceptTcpClient(TCPConnectCallback, null);
           
        }
        private static void TCPConnectCallback(IAsyncResult _result)
        {
            TcpClient _client = tcpListener.EndAcceptTcpClient(_result);
        }
    }
}

CSProj:

<Project Sdk="***">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

</Project>

All of which are in the same location

1
Why do you expect your code to work with Cloud Run? Cloud Run expects a response to an HTTP Request. Your code just closes the connection unless you are leaving out additional code.John Hanley
@JohnHanley Oh wow thank you. So I guess my question then is where am I supposed to deploy this code then? Or is it that not possible on Google Cloud?user13563819
Edit your question with more details. Your code does not do anything other than listen, accept and close.John Hanley
@JohnHanley I thought this was redundant. Here is all of my code: github.com/robin271/Server \ I still need to work on it on but the gist of this project is in my opinion conveyed; it is supposed to assign every incoming tcp connection to a individual server.user13563819

1 Answers

1
votes

The solution is to alter the dockerfile like so:

FROM mcr.microsoft.com/dotnet/sdk:3.1 WORKDIR /app

COPY . .

ENTRYPOINT ["dotnet", "run"]